Buffer pools compile

reviewable/pr8239/r2
Craig Tiller 8 years ago
parent 45881861dc
commit 86958768b4
  1. 6
      BUILD
  2. 1
      build.yaml
  3. 2
      gRPC-Core.podspec
  4. 1
      grpc.gemspec
  5. 1
      package.xml
  6. 4
      src/core/ext/transport/chttp2/client/insecure/channel_create.c
  7. 6
      src/core/ext/transport/chttp2/client/insecure/channel_create_posix.c
  8. 7
      src/core/ext/transport/chttp2/client/secure/secure_channel_create.c
  9. 4
      src/core/ext/transport/chttp2/server/insecure/server_chttp2.c
  10. 2
      src/core/ext/transport/chttp2/server/insecure/server_chttp2_posix.c
  11. 13
      src/core/lib/http/httpcli.c
  12. 17
      src/core/lib/iomgr/buffer_pool.c
  13. 2
      src/core/lib/iomgr/buffer_pool.h
  14. 4
      src/core/lib/iomgr/tcp_client.h
  15. 52
      src/core/lib/iomgr/tcp_client_posix.c
  16. 45
      src/core/lib/iomgr/tcp_client_posix.h
  17. 1
      tools/doxygen/Doxyfile.c++.internal
  18. 1
      tools/doxygen/Doxyfile.core.internal
  19. 2
      tools/run_tests/sources_and_headers.json
  20. 1
      vsprojects/vcxproj/grpc++/grpc++.vcxproj
  21. 3
      vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters
  22. 1
      vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj
  23. 3
      vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters
  24. 1
      vsprojects/vcxproj/grpc/grpc.vcxproj
  25. 3
      vsprojects/vcxproj/grpc/grpc.vcxproj.filters
  26. 1
      vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj
  27. 3
      vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters
  28. 1
      vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj
  29. 3
      vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters

@ -209,6 +209,7 @@ cc_library(
"src/core/lib/iomgr/socket_utils_posix.h", "src/core/lib/iomgr/socket_utils_posix.h",
"src/core/lib/iomgr/socket_windows.h", "src/core/lib/iomgr/socket_windows.h",
"src/core/lib/iomgr/tcp_client.h", "src/core/lib/iomgr/tcp_client.h",
"src/core/lib/iomgr/tcp_client_posix.h",
"src/core/lib/iomgr/tcp_posix.h", "src/core/lib/iomgr/tcp_posix.h",
"src/core/lib/iomgr/tcp_server.h", "src/core/lib/iomgr/tcp_server.h",
"src/core/lib/iomgr/tcp_windows.h", "src/core/lib/iomgr/tcp_windows.h",
@ -606,6 +607,7 @@ cc_library(
"src/core/lib/iomgr/socket_utils_posix.h", "src/core/lib/iomgr/socket_utils_posix.h",
"src/core/lib/iomgr/socket_windows.h", "src/core/lib/iomgr/socket_windows.h",
"src/core/lib/iomgr/tcp_client.h", "src/core/lib/iomgr/tcp_client.h",
"src/core/lib/iomgr/tcp_client_posix.h",
"src/core/lib/iomgr/tcp_posix.h", "src/core/lib/iomgr/tcp_posix.h",
"src/core/lib/iomgr/tcp_server.h", "src/core/lib/iomgr/tcp_server.h",
"src/core/lib/iomgr/tcp_windows.h", "src/core/lib/iomgr/tcp_windows.h",
@ -958,6 +960,7 @@ cc_library(
"src/core/lib/iomgr/socket_utils_posix.h", "src/core/lib/iomgr/socket_utils_posix.h",
"src/core/lib/iomgr/socket_windows.h", "src/core/lib/iomgr/socket_windows.h",
"src/core/lib/iomgr/tcp_client.h", "src/core/lib/iomgr/tcp_client.h",
"src/core/lib/iomgr/tcp_client_posix.h",
"src/core/lib/iomgr/tcp_posix.h", "src/core/lib/iomgr/tcp_posix.h",
"src/core/lib/iomgr/tcp_server.h", "src/core/lib/iomgr/tcp_server.h",
"src/core/lib/iomgr/tcp_windows.h", "src/core/lib/iomgr/tcp_windows.h",
@ -1307,6 +1310,7 @@ cc_library(
"src/core/lib/iomgr/socket_utils_posix.h", "src/core/lib/iomgr/socket_utils_posix.h",
"src/core/lib/iomgr/socket_windows.h", "src/core/lib/iomgr/socket_windows.h",
"src/core/lib/iomgr/tcp_client.h", "src/core/lib/iomgr/tcp_client.h",
"src/core/lib/iomgr/tcp_client_posix.h",
"src/core/lib/iomgr/tcp_posix.h", "src/core/lib/iomgr/tcp_posix.h",
"src/core/lib/iomgr/tcp_server.h", "src/core/lib/iomgr/tcp_server.h",
"src/core/lib/iomgr/tcp_windows.h", "src/core/lib/iomgr/tcp_windows.h",
@ -1715,6 +1719,7 @@ cc_library(
"src/core/lib/iomgr/socket_utils_posix.h", "src/core/lib/iomgr/socket_utils_posix.h",
"src/core/lib/iomgr/socket_windows.h", "src/core/lib/iomgr/socket_windows.h",
"src/core/lib/iomgr/tcp_client.h", "src/core/lib/iomgr/tcp_client.h",
"src/core/lib/iomgr/tcp_client_posix.h",
"src/core/lib/iomgr/tcp_posix.h", "src/core/lib/iomgr/tcp_posix.h",
"src/core/lib/iomgr/tcp_server.h", "src/core/lib/iomgr/tcp_server.h",
"src/core/lib/iomgr/tcp_windows.h", "src/core/lib/iomgr/tcp_windows.h",
@ -2430,6 +2435,7 @@ objc_library(
"src/core/lib/iomgr/socket_utils_posix.h", "src/core/lib/iomgr/socket_utils_posix.h",
"src/core/lib/iomgr/socket_windows.h", "src/core/lib/iomgr/socket_windows.h",
"src/core/lib/iomgr/tcp_client.h", "src/core/lib/iomgr/tcp_client.h",
"src/core/lib/iomgr/tcp_client_posix.h",
"src/core/lib/iomgr/tcp_posix.h", "src/core/lib/iomgr/tcp_posix.h",
"src/core/lib/iomgr/tcp_server.h", "src/core/lib/iomgr/tcp_server.h",
"src/core/lib/iomgr/tcp_windows.h", "src/core/lib/iomgr/tcp_windows.h",

@ -213,6 +213,7 @@ filegroups:
- src/core/lib/iomgr/socket_utils_posix.h - src/core/lib/iomgr/socket_utils_posix.h
- src/core/lib/iomgr/socket_windows.h - src/core/lib/iomgr/socket_windows.h
- src/core/lib/iomgr/tcp_client.h - src/core/lib/iomgr/tcp_client.h
- src/core/lib/iomgr/tcp_client_posix.h
- src/core/lib/iomgr/tcp_posix.h - src/core/lib/iomgr/tcp_posix.h
- src/core/lib/iomgr/tcp_server.h - src/core/lib/iomgr/tcp_server.h
- src/core/lib/iomgr/tcp_windows.h - src/core/lib/iomgr/tcp_windows.h

@ -296,6 +296,7 @@ Pod::Spec.new do |s|
'src/core/lib/iomgr/socket_utils_posix.h', 'src/core/lib/iomgr/socket_utils_posix.h',
'src/core/lib/iomgr/socket_windows.h', 'src/core/lib/iomgr/socket_windows.h',
'src/core/lib/iomgr/tcp_client.h', 'src/core/lib/iomgr/tcp_client.h',
'src/core/lib/iomgr/tcp_client_posix.h',
'src/core/lib/iomgr/tcp_posix.h', 'src/core/lib/iomgr/tcp_posix.h',
'src/core/lib/iomgr/tcp_server.h', 'src/core/lib/iomgr/tcp_server.h',
'src/core/lib/iomgr/tcp_windows.h', 'src/core/lib/iomgr/tcp_windows.h',
@ -665,6 +666,7 @@ Pod::Spec.new do |s|
'src/core/lib/iomgr/socket_utils_posix.h', 'src/core/lib/iomgr/socket_utils_posix.h',
'src/core/lib/iomgr/socket_windows.h', 'src/core/lib/iomgr/socket_windows.h',
'src/core/lib/iomgr/tcp_client.h', 'src/core/lib/iomgr/tcp_client.h',
'src/core/lib/iomgr/tcp_client_posix.h',
'src/core/lib/iomgr/tcp_posix.h', 'src/core/lib/iomgr/tcp_posix.h',
'src/core/lib/iomgr/tcp_server.h', 'src/core/lib/iomgr/tcp_server.h',
'src/core/lib/iomgr/tcp_windows.h', 'src/core/lib/iomgr/tcp_windows.h',

@ -216,6 +216,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/iomgr/socket_utils_posix.h ) s.files += %w( src/core/lib/iomgr/socket_utils_posix.h )
s.files += %w( src/core/lib/iomgr/socket_windows.h ) s.files += %w( src/core/lib/iomgr/socket_windows.h )
s.files += %w( src/core/lib/iomgr/tcp_client.h ) s.files += %w( src/core/lib/iomgr/tcp_client.h )
s.files += %w( src/core/lib/iomgr/tcp_client_posix.h )
s.files += %w( src/core/lib/iomgr/tcp_posix.h ) s.files += %w( src/core/lib/iomgr/tcp_posix.h )
s.files += %w( src/core/lib/iomgr/tcp_server.h ) s.files += %w( src/core/lib/iomgr/tcp_server.h )
s.files += %w( src/core/lib/iomgr/tcp_windows.h ) s.files += %w( src/core/lib/iomgr/tcp_windows.h )

@ -223,6 +223,7 @@
<file baseinstalldir="/" name="src/core/lib/iomgr/socket_utils_posix.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/iomgr/socket_utils_posix.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/socket_windows.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/iomgr/socket_windows.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/tcp_client.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/iomgr/tcp_client.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/tcp_client_posix.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/tcp_posix.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/iomgr/tcp_posix.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/tcp_server.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/iomgr/tcp_server.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/iomgr/tcp_windows.h" role="src" /> <file baseinstalldir="/" name="src/core/lib/iomgr/tcp_windows.h" role="src" />

@ -149,8 +149,8 @@ static void connector_connect(grpc_exec_ctx *exec_ctx, grpc_connector *con,
c->tcp = NULL; c->tcp = NULL;
grpc_closure_init(&c->connected, connected, c); grpc_closure_init(&c->connected, connected, c);
grpc_tcp_client_connect(exec_ctx, &c->connected, &c->tcp, grpc_tcp_client_connect(exec_ctx, &c->connected, &c->tcp,
args->interested_parties, args->addr, args->addr_len, args->interested_parties, args->channel_args,
args->deadline); args->addr, args->addr_len, args->deadline);
} }
static const grpc_connector_vtable connector_vtable = { static const grpc_connector_vtable connector_vtable = {

@ -44,6 +44,7 @@
#include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/channel_args.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/exec_ctx.h"
#include "src/core/lib/iomgr/tcp_client_posix.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"
@ -65,9 +66,8 @@ grpc_channel *grpc_insecure_channel_create_from_fd(
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_endpoint *client = grpc_tcp_client_create_from_fd(
grpc_tcp_create(grpc_fd_create(fd, "client"), &exec_ctx, grpc_fd_create(fd, "client"), args, "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);

@ -207,9 +207,10 @@ static void connector_connect(grpc_exec_ctx *exec_ctx, grpc_connector *con,
GPR_ASSERT(c->connecting_endpoint == NULL); GPR_ASSERT(c->connecting_endpoint == NULL);
gpr_mu_unlock(&c->mu); gpr_mu_unlock(&c->mu);
grpc_closure_init(&c->connected_closure, connected, c); grpc_closure_init(&c->connected_closure, connected, c);
grpc_tcp_client_connect( grpc_tcp_client_connect(exec_ctx, &c->connected_closure,
exec_ctx, &c->connected_closure, &c->newly_connecting_endpoint, &c->newly_connecting_endpoint,
args->interested_parties, args->addr, args->addr_len, args->deadline); args->interested_parties, args->channel_args,
args->addr, args->addr_len, args->deadline);
} }
static const grpc_connector_vtable connector_vtable = { static const grpc_connector_vtable connector_vtable = {

@ -139,8 +139,8 @@ int grpc_server_add_insecure_http2_port(grpc_server *server, const char *addr) {
goto error; goto error;
} }
err = err = grpc_tcp_server_create(&exec_ctx, NULL,
grpc_tcp_server_create(NULL, grpc_server_get_channel_args(server), &tcp); grpc_server_get_channel_args(server), &tcp);
if (err != GRPC_ERROR_NONE) { if (err != GRPC_ERROR_NONE) {
goto error; goto error;
} }

@ -58,7 +58,7 @@ void grpc_server_add_insecure_channel_from_fd(grpc_server *server,
gpr_asprintf(&name, "fd:%d", fd); gpr_asprintf(&name, "fd:%d", fd);
grpc_endpoint *server_endpoint = grpc_tcp_create( grpc_endpoint *server_endpoint = grpc_tcp_create(
grpc_fd_create(fd, name), GRPC_TCP_DEFAULT_READ_SLICE_SIZE, name); grpc_fd_create(fd, name), NULL, GRPC_TCP_DEFAULT_READ_SLICE_SIZE, name);
gpr_free(name); gpr_free(name);

@ -226,10 +226,15 @@ static void next_address(grpc_exec_ctx *exec_ctx, internal_request *req,
} }
addr = &req->addresses->addrs[req->next_address++]; addr = &req->addresses->addrs[req->next_address++];
grpc_closure_init(&req->connected, on_connected, req); grpc_closure_init(&req->connected, on_connected, req);
grpc_tcp_client_connect(exec_ctx, &req->connected, &req->ep, grpc_arg arg;
req->context->pollset_set, req->buffer_pool, arg.key = GRPC_ARG_BUFFER_POOL;
(struct sockaddr *)&addr->addr, addr->len, arg.type = GRPC_ARG_POINTER;
req->deadline); arg.value.pointer.p = req->buffer_pool;
arg.value.pointer.vtable = grpc_buffer_pool_arg_vtable();
grpc_channel_args args = {1, &arg};
grpc_tcp_client_connect(
exec_ctx, &req->connected, &req->ep, req->context->pollset_set, &args,
(struct sockaddr *)&addr->addr, addr->len, req->deadline);
} }
static void on_resolved(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { static void on_resolved(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {

@ -33,6 +33,8 @@
#include "src/core/lib/iomgr/buffer_pool.h" #include "src/core/lib/iomgr/buffer_pool.h"
#include <string.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -364,6 +366,21 @@ void grpc_buffer_pool_resize(grpc_buffer_pool *buffer_pool, size_t size) {
grpc_exec_ctx_finish(&exec_ctx); grpc_exec_ctx_finish(&exec_ctx);
} }
grpc_buffer_pool *grpc_buffer_pool_from_channel_args(
grpc_channel_args *channel_args) {
for (size_t i = 0; i < channel_args->num_args; i++) {
if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_BUFFER_POOL)) {
if (channel_args->args[i].type == GRPC_ARG_POINTER) {
return grpc_buffer_pool_internal_ref(
channel_args->args[i].value.pointer.p);
} else {
gpr_log(GPR_DEBUG, GRPC_ARG_BUFFER_POOL " should be a pointer");
}
}
}
return grpc_buffer_pool_create();
}
/******************************************************************************* /*******************************************************************************
* grpc_buffer_user api * grpc_buffer_user api
*/ */

@ -41,6 +41,8 @@
grpc_buffer_pool *grpc_buffer_pool_internal_ref(grpc_buffer_pool *buffer_pool); grpc_buffer_pool *grpc_buffer_pool_internal_ref(grpc_buffer_pool *buffer_pool);
void grpc_buffer_pool_internal_unref(grpc_exec_ctx *exec_ctx, void grpc_buffer_pool_internal_unref(grpc_exec_ctx *exec_ctx,
grpc_buffer_pool *buffer_pool); grpc_buffer_pool *buffer_pool);
grpc_buffer_pool *grpc_buffer_pool_from_channel_args(
grpc_channel_args *channel_args);
typedef enum { typedef enum {
GRPC_BULIST_AWAITING_ALLOCATION, GRPC_BULIST_AWAITING_ALLOCATION,

@ -39,6 +39,8 @@
#include "src/core/lib/iomgr/pollset_set.h" #include "src/core/lib/iomgr/pollset_set.h"
#include "src/core/lib/iomgr/sockaddr.h" #include "src/core/lib/iomgr/sockaddr.h"
#define GRPC_ARG_TCP_READ_CHUNK_SIZE "grpc.experimental.tcp_read_chunk_size"
/* Asynchronously connect to an address (specified as (addr, len)), and call /* Asynchronously connect to an address (specified as (addr, len)), and call
cb with arg and the completed connection when done (or call cb with arg and cb with arg and the completed connection when done (or call cb with arg and
NULL on failure). NULL on failure).
@ -47,7 +49,7 @@
void grpc_tcp_client_connect(grpc_exec_ctx *exec_ctx, grpc_closure *on_connect, void grpc_tcp_client_connect(grpc_exec_ctx *exec_ctx, grpc_closure *on_connect,
grpc_endpoint **endpoint, grpc_endpoint **endpoint,
grpc_pollset_set *interested_parties, grpc_pollset_set *interested_parties,
grpc_buffer_pool *buffer_pool, const grpc_channel_args *channel_args,
const struct sockaddr *addr, size_t addr_len, const struct sockaddr *addr, size_t addr_len,
gpr_timespec deadline); gpr_timespec deadline);

@ -35,7 +35,7 @@
#ifdef GPR_POSIX_SOCKET #ifdef GPR_POSIX_SOCKET
#include "src/core/lib/iomgr/tcp_client.h" #include "src/core/lib/iomgr/tcp_client_posix.h"
#include <errno.h> #include <errno.h>
#include <netinet/in.h> #include <netinet/in.h>
@ -47,6 +47,7 @@
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
#include <grpc/support/time.h> #include <grpc/support/time.h>
#include "src/core/lib/channel/channel_args.h"
#include "src/core/lib/iomgr/ev_posix.h" #include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/iomgr_posix.h" #include "src/core/lib/iomgr/iomgr_posix.h"
#include "src/core/lib/iomgr/sockaddr_utils.h" #include "src/core/lib/iomgr/sockaddr_utils.h"
@ -69,7 +70,7 @@ typedef struct {
char *addr_str; char *addr_str;
grpc_endpoint **ep; grpc_endpoint **ep;
grpc_closure *closure; grpc_closure *closure;
grpc_buffer_pool *buffer_pool; grpc_channel_args *channel_args;
} async_connect; } async_connect;
static grpc_error *prepare_socket(const struct sockaddr *addr, int fd) { static grpc_error *prepare_socket(const struct sockaddr *addr, int fd) {
@ -115,11 +116,38 @@ static void tc_on_alarm(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) {
if (done) { if (done) {
gpr_mu_destroy(&ac->mu); gpr_mu_destroy(&ac->mu);
gpr_free(ac->addr_str); gpr_free(ac->addr_str);
grpc_buffer_pool_internal_unref(exec_ctx, ac->buffer_pool); grpc_channel_args_destroy(ac->channel_args);
gpr_free(ac); gpr_free(ac);
} }
} }
grpc_endpoint *grpc_tcp_client_create_from_fd(
grpc_exec_ctx *exec_ctx, grpc_fd *fd, const grpc_channel_args *channel_args,
const char *addr_str) {
size_t tcp_read_chunk_size = GRPC_TCP_DEFAULT_READ_SLICE_SIZE;
grpc_buffer_pool *buffer_pool = grpc_buffer_pool_create();
if (channel_args != NULL) {
for (size_t i = 0; i < channel_args->num_args; i++) {
if (0 ==
strcmp(channel_args->args[i].key, GRPC_ARG_TCP_READ_CHUNK_SIZE)) {
grpc_integer_options options = {(int)tcp_read_chunk_size, 1,
8 * 1024 * 1024};
tcp_read_chunk_size = (size_t)grpc_channel_arg_get_integer(
&channel_args->args[i], options);
} else if (0 == strcmp(channel_args->args[i].key, GRPC_ARG_BUFFER_POOL)) {
grpc_buffer_pool_internal_unref(exec_ctx, buffer_pool);
buffer_pool = grpc_buffer_pool_internal_ref(
channel_args->args[i].value.pointer.p);
}
}
}
grpc_endpoint *ep =
grpc_tcp_create(fd, buffer_pool, tcp_read_chunk_size, addr_str);
grpc_buffer_pool_internal_unref(exec_ctx, buffer_pool);
return ep;
}
static void on_writable(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) { static void on_writable(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) {
async_connect *ac = acp; async_connect *ac = acp;
int so_error = 0; int so_error = 0;
@ -192,8 +220,8 @@ static void on_writable(grpc_exec_ctx *exec_ctx, void *acp, grpc_error *error) {
} }
} else { } else {
grpc_pollset_set_del_fd(exec_ctx, ac->interested_parties, fd); grpc_pollset_set_del_fd(exec_ctx, ac->interested_parties, fd);
*ep = grpc_tcp_create(fd, ac->buffer_pool, *ep = grpc_tcp_client_create_from_fd(exec_ctx, fd, ac->channel_args,
GRPC_TCP_DEFAULT_READ_SLICE_SIZE, ac->addr_str); ac->addr_str);
fd = NULL; fd = NULL;
goto finish; goto finish;
} }
@ -230,7 +258,7 @@ finish:
static void tcp_client_connect_impl(grpc_exec_ctx *exec_ctx, static void tcp_client_connect_impl(grpc_exec_ctx *exec_ctx,
grpc_closure *closure, grpc_endpoint **ep, grpc_closure *closure, grpc_endpoint **ep,
grpc_pollset_set *interested_parties, grpc_pollset_set *interested_parties,
grpc_buffer_pool *buffer_pool, const grpc_channel_args *channel_args,
const struct sockaddr *addr, const struct sockaddr *addr,
size_t addr_len, gpr_timespec deadline) { size_t addr_len, gpr_timespec deadline) {
int fd; int fd;
@ -279,8 +307,8 @@ static void tcp_client_connect_impl(grpc_exec_ctx *exec_ctx,
fdobj = grpc_fd_create(fd, name); fdobj = grpc_fd_create(fd, name);
if (err >= 0) { if (err >= 0) {
*ep = grpc_tcp_create(fdobj, buffer_pool, GRPC_TCP_DEFAULT_READ_SLICE_SIZE, *ep =
addr_str); grpc_tcp_client_create_from_fd(exec_ctx, fdobj, channel_args, addr_str);
grpc_exec_ctx_sched(exec_ctx, closure, GRPC_ERROR_NONE, NULL); grpc_exec_ctx_sched(exec_ctx, closure, GRPC_ERROR_NONE, NULL);
goto done; goto done;
} }
@ -305,7 +333,7 @@ static void tcp_client_connect_impl(grpc_exec_ctx *exec_ctx,
ac->refs = 2; ac->refs = 2;
ac->write_closure.cb = on_writable; ac->write_closure.cb = on_writable;
ac->write_closure.cb_arg = ac; ac->write_closure.cb_arg = ac;
ac->buffer_pool = grpc_buffer_pool_internal_ref(buffer_pool); ac->channel_args = grpc_channel_args_copy(channel_args);
if (grpc_tcp_trace) { if (grpc_tcp_trace) {
gpr_log(GPR_DEBUG, "CLIENT_CONNECT: %s: asynchronously connecting", gpr_log(GPR_DEBUG, "CLIENT_CONNECT: %s: asynchronously connecting",
@ -327,18 +355,18 @@ done:
// overridden by api_fuzzer.c // overridden by api_fuzzer.c
void (*grpc_tcp_client_connect_impl)( void (*grpc_tcp_client_connect_impl)(
grpc_exec_ctx *exec_ctx, grpc_closure *closure, grpc_endpoint **ep, grpc_exec_ctx *exec_ctx, grpc_closure *closure, grpc_endpoint **ep,
grpc_pollset_set *interested_parties, grpc_buffer_pool *buffer_pool, grpc_pollset_set *interested_parties, const grpc_channel_args *channel_args,
const struct sockaddr *addr, size_t addr_len, const struct sockaddr *addr, size_t addr_len,
gpr_timespec deadline) = tcp_client_connect_impl; gpr_timespec deadline) = tcp_client_connect_impl;
void grpc_tcp_client_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure, void grpc_tcp_client_connect(grpc_exec_ctx *exec_ctx, grpc_closure *closure,
grpc_endpoint **ep, grpc_endpoint **ep,
grpc_pollset_set *interested_parties, grpc_pollset_set *interested_parties,
grpc_buffer_pool *buffer_pool, const grpc_channel_args *channel_args,
const struct sockaddr *addr, size_t addr_len, const struct sockaddr *addr, size_t addr_len,
gpr_timespec deadline) { gpr_timespec deadline) {
grpc_tcp_client_connect_impl(exec_ctx, closure, ep, interested_parties, grpc_tcp_client_connect_impl(exec_ctx, closure, ep, interested_parties,
buffer_pool, addr, addr_len, deadline); channel_args, addr, addr_len, deadline);
} }
#endif #endif

@ -0,0 +1,45 @@
/*
*
* Copyright 2015, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GRPC_CORE_LIB_IOMGR_TCP_CLIENT_POSIX_H
#define GRPC_CORE_LIB_IOMGR_TCP_CLIENT_POSIX_H
#include "src/core/lib/iomgr/endpoint.h"
#include "src/core/lib/iomgr/ev_posix.h"
#include "src/core/lib/iomgr/tcp_client.h"
grpc_endpoint *grpc_tcp_client_create_from_fd(
grpc_exec_ctx *exec_ctx, grpc_fd *fd, const grpc_channel_args *channel_args,
const char *addr_str);
#endif

@ -917,6 +917,7 @@ src/core/lib/iomgr/sockaddr_windows.h \
src/core/lib/iomgr/socket_utils_posix.h \ src/core/lib/iomgr/socket_utils_posix.h \
src/core/lib/iomgr/socket_windows.h \ src/core/lib/iomgr/socket_windows.h \
src/core/lib/iomgr/tcp_client.h \ src/core/lib/iomgr/tcp_client.h \
src/core/lib/iomgr/tcp_client_posix.h \
src/core/lib/iomgr/tcp_posix.h \ src/core/lib/iomgr/tcp_posix.h \
src/core/lib/iomgr/tcp_server.h \ src/core/lib/iomgr/tcp_server.h \
src/core/lib/iomgr/tcp_windows.h \ src/core/lib/iomgr/tcp_windows.h \

@ -833,6 +833,7 @@ src/core/lib/iomgr/sockaddr_windows.h \
src/core/lib/iomgr/socket_utils_posix.h \ src/core/lib/iomgr/socket_utils_posix.h \
src/core/lib/iomgr/socket_windows.h \ src/core/lib/iomgr/socket_windows.h \
src/core/lib/iomgr/tcp_client.h \ src/core/lib/iomgr/tcp_client.h \
src/core/lib/iomgr/tcp_client_posix.h \
src/core/lib/iomgr/tcp_posix.h \ src/core/lib/iomgr/tcp_posix.h \
src/core/lib/iomgr/tcp_server.h \ src/core/lib/iomgr/tcp_server.h \
src/core/lib/iomgr/tcp_windows.h \ src/core/lib/iomgr/tcp_windows.h \

@ -5998,6 +5998,7 @@
"src/core/lib/iomgr/socket_utils_posix.h", "src/core/lib/iomgr/socket_utils_posix.h",
"src/core/lib/iomgr/socket_windows.h", "src/core/lib/iomgr/socket_windows.h",
"src/core/lib/iomgr/tcp_client.h", "src/core/lib/iomgr/tcp_client.h",
"src/core/lib/iomgr/tcp_client_posix.h",
"src/core/lib/iomgr/tcp_posix.h", "src/core/lib/iomgr/tcp_posix.h",
"src/core/lib/iomgr/tcp_server.h", "src/core/lib/iomgr/tcp_server.h",
"src/core/lib/iomgr/tcp_windows.h", "src/core/lib/iomgr/tcp_windows.h",
@ -6136,6 +6137,7 @@
"src/core/lib/iomgr/socket_windows.h", "src/core/lib/iomgr/socket_windows.h",
"src/core/lib/iomgr/tcp_client.h", "src/core/lib/iomgr/tcp_client.h",
"src/core/lib/iomgr/tcp_client_posix.c", "src/core/lib/iomgr/tcp_client_posix.c",
"src/core/lib/iomgr/tcp_client_posix.h",
"src/core/lib/iomgr/tcp_client_windows.c", "src/core/lib/iomgr/tcp_client_windows.c",
"src/core/lib/iomgr/tcp_posix.c", "src/core/lib/iomgr/tcp_posix.c",
"src/core/lib/iomgr/tcp_posix.h", "src/core/lib/iomgr/tcp_posix.h",

@ -417,6 +417,7 @@
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils_posix.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils_posix.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_windows.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_windows.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client_posix.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_posix.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_posix.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_server.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_server.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_windows.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_windows.h" />

@ -851,6 +851,9 @@
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client.h"> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client.h">
<Filter>src\core\lib\iomgr</Filter> <Filter>src\core\lib\iomgr</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client_posix.h">
<Filter>src\core\lib\iomgr</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_posix.h"> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_posix.h">
<Filter>src\core\lib\iomgr</Filter> <Filter>src\core\lib\iomgr</Filter>
</ClInclude> </ClInclude>

@ -413,6 +413,7 @@
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils_posix.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils_posix.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_windows.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_windows.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client_posix.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_posix.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_posix.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_server.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_server.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_windows.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_windows.h" />

@ -824,6 +824,9 @@
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client.h"> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client.h">
<Filter>src\core\lib\iomgr</Filter> <Filter>src\core\lib\iomgr</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client_posix.h">
<Filter>src\core\lib\iomgr</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_posix.h"> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_posix.h">
<Filter>src\core\lib\iomgr</Filter> <Filter>src\core\lib\iomgr</Filter>
</ClInclude> </ClInclude>

@ -342,6 +342,7 @@
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils_posix.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils_posix.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_windows.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_windows.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client_posix.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_posix.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_posix.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_server.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_server.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_windows.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_windows.h" />

@ -803,6 +803,9 @@
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client.h"> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client.h">
<Filter>src\core\lib\iomgr</Filter> <Filter>src\core\lib\iomgr</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client_posix.h">
<Filter>src\core\lib\iomgr</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_posix.h"> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_posix.h">
<Filter>src\core\lib\iomgr</Filter> <Filter>src\core\lib\iomgr</Filter>
</ClInclude> </ClInclude>

@ -233,6 +233,7 @@
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils_posix.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils_posix.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_windows.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_windows.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client_posix.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_posix.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_posix.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_server.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_server.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_windows.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_windows.h" />

@ -581,6 +581,9 @@
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client.h"> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client.h">
<Filter>src\core\lib\iomgr</Filter> <Filter>src\core\lib\iomgr</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client_posix.h">
<Filter>src\core\lib\iomgr</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_posix.h"> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_posix.h">
<Filter>src\core\lib\iomgr</Filter> <Filter>src\core\lib\iomgr</Filter>
</ClInclude> </ClInclude>

@ -332,6 +332,7 @@
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils_posix.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_utils_posix.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_windows.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\socket_windows.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client_posix.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_posix.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_posix.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_server.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_server.h" />
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_windows.h" /> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_windows.h" />

@ -713,6 +713,9 @@
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client.h"> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client.h">
<Filter>src\core\lib\iomgr</Filter> <Filter>src\core\lib\iomgr</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_client_posix.h">
<Filter>src\core\lib\iomgr</Filter>
</ClInclude>
<ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_posix.h"> <ClInclude Include="$(SolutionDir)\..\src\core\lib\iomgr\tcp_posix.h">
<Filter>src\core\lib\iomgr</Filter> <Filter>src\core\lib\iomgr</Filter>
</ClInclude> </ClInclude>

Loading…
Cancel
Save