|
|
@ -41,34 +41,32 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" |
|
|
|
#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" |
|
|
|
#include "src/core/lib/channel/channel_args.h" |
|
|
|
#include "src/core/lib/channel/channel_args.h" |
|
|
|
#include "src/core/lib/transport/transport.h" |
|
|
|
|
|
|
|
#include "src/core/lib/iomgr/exec_ctx.h" |
|
|
|
|
|
|
|
#include "src/core/lib/iomgr/endpoint.h" |
|
|
|
#include "src/core/lib/iomgr/endpoint.h" |
|
|
|
|
|
|
|
#include "src/core/lib/iomgr/exec_ctx.h" |
|
|
|
#include "src/core/lib/iomgr/tcp_posix.h" |
|
|
|
#include "src/core/lib/iomgr/tcp_posix.h" |
|
|
|
#include "src/core/lib/surface/api_trace.h" |
|
|
|
#include "src/core/lib/surface/api_trace.h" |
|
|
|
#include "src/core/lib/surface/channel.h" |
|
|
|
#include "src/core/lib/surface/channel.h" |
|
|
|
|
|
|
|
#include "src/core/lib/transport/transport.h" |
|
|
|
|
|
|
|
|
|
|
|
grpc_channel *grpc_insecure_channel_create_from_fd( |
|
|
|
grpc_channel *grpc_insecure_channel_create_from_fd( |
|
|
|
const char *target, int fd, const grpc_channel_args *args) { |
|
|
|
const char *target, int fd, const grpc_channel_args *args) { |
|
|
|
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
|
|
|
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
|
|
|
GRPC_API_TRACE( |
|
|
|
GRPC_API_TRACE("grpc_insecure_channel_create(target=%p, fd=%d, args=%p)", 3, |
|
|
|
"grpc_insecure_channel_create(target=%p, fd=%d, args=%p)", 3, |
|
|
|
|
|
|
|
(target, fd, args)); |
|
|
|
(target, fd, args)); |
|
|
|
|
|
|
|
|
|
|
|
grpc_arg default_authority_arg; |
|
|
|
grpc_arg default_authority_arg; |
|
|
|
default_authority_arg.type = GRPC_ARG_STRING; |
|
|
|
default_authority_arg.type = GRPC_ARG_STRING; |
|
|
|
default_authority_arg.key = GRPC_ARG_DEFAULT_AUTHORITY; |
|
|
|
default_authority_arg.key = GRPC_ARG_DEFAULT_AUTHORITY; |
|
|
|
default_authority_arg.value.string = "test.authority"; |
|
|
|
default_authority_arg.value.string = "test.authority"; |
|
|
|
grpc_channel_args *final_args = grpc_channel_args_copy_and_add( |
|
|
|
grpc_channel_args *final_args = |
|
|
|
args, &default_authority_arg, 1); |
|
|
|
grpc_channel_args_copy_and_add(args, &default_authority_arg, 1); |
|
|
|
|
|
|
|
|
|
|
|
int flags = fcntl(fd, F_GETFL, 0); |
|
|
|
int flags = fcntl(fd, F_GETFL, 0); |
|
|
|
GPR_ASSERT(fcntl(fd, F_SETFL, flags | O_NONBLOCK) == 0); |
|
|
|
GPR_ASSERT(fcntl(fd, F_SETFL, flags | O_NONBLOCK) == 0); |
|
|
|
|
|
|
|
|
|
|
|
grpc_endpoint *client = grpc_tcp_create( |
|
|
|
grpc_endpoint *client = |
|
|
|
grpc_fd_create(fd, "client"), GRPC_TCP_DEFAULT_READ_SLICE_SIZE, |
|
|
|
grpc_tcp_create(grpc_fd_create(fd, "client"), |
|
|
|
"fd-client"); |
|
|
|
GRPC_TCP_DEFAULT_READ_SLICE_SIZE, "fd-client"); |
|
|
|
|
|
|
|
|
|
|
|
grpc_transport *transport = |
|
|
|
grpc_transport *transport = |
|
|
|
grpc_create_chttp2_transport(&exec_ctx, final_args, client, 1); |
|
|
|
grpc_create_chttp2_transport(&exec_ctx, final_args, client, 1); |
|
|
@ -85,4 +83,12 @@ grpc_channel *grpc_insecure_channel_create_from_fd( |
|
|
|
"Failed to create client channel"); |
|
|
|
"Failed to create client channel"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#else // !GPR_SUPPORT_CHANNELS_FROM_FD
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
grpc_channel *grpc_insecure_channel_create_from_fd( |
|
|
|
|
|
|
|
const char *target, int fd, const grpc_channel_args *args) { |
|
|
|
|
|
|
|
GPR_ASSERT(0); |
|
|
|
|
|
|
|
return NULL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endif // GPR_SUPPORT_CHANNELS_FROM_FD
|
|
|
|
#endif // GPR_SUPPORT_CHANNELS_FROM_FD
|
|
|
|