Merge branch 'reuse_port' of github.com:ctiller/grpc into reuse_port

pull/6645/head
Craig Tiller 9 years ago
commit dfd07f36fd
  1. 1
      src/core/lib/iomgr/tcp_server_posix.c
  2. 10
      test/core/iomgr/tcp_server_posix_test.c
  3. 2
      test/core/surface/concurrent_connectivity_test.c
  4. 8
      test/core/surface/server_chttp2_test.c
  5. 10
      test/core/surface/server_test.c
  6. 2
      test/core/util/test_tcp_server.c

@ -488,6 +488,7 @@ static grpc_error *clone_port(grpc_tcp_listener *listener, unsigned count) {
err = prepare_socket(fd, &listener->addr.sockaddr, listener->addr_len, true,
&port);
if (err != GRPC_ERROR_NONE) return err;
listener->server->nports++;
grpc_sockaddr_to_string(&addr_str, &listener->addr.sockaddr, 1);
gpr_asprintf(&name, "tcp-server-listener:%s/clone-%d", addr_str, i);
sp = gpr_malloc(sizeof(grpc_tcp_listener));

@ -128,7 +128,7 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp,
static void test_no_op(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_tcp_server *s;
GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, &s));
GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, NULL, &s));
grpc_tcp_server_unref(&exec_ctx, s);
grpc_exec_ctx_finish(&exec_ctx);
}
@ -136,7 +136,7 @@ static void test_no_op(void) {
static void test_no_op_with_start(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_tcp_server *s;
GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, &s));
GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, NULL, &s));
LOG_TEST("test_no_op_with_start");
grpc_tcp_server_start(&exec_ctx, s, NULL, 0, on_connect, NULL);
grpc_tcp_server_unref(&exec_ctx, s);
@ -147,7 +147,7 @@ static void test_no_op_with_port(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
struct sockaddr_in addr;
grpc_tcp_server *s;
GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, &s));
GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, NULL, &s));
LOG_TEST("test_no_op_with_port");
memset(&addr, 0, sizeof(addr));
@ -165,7 +165,7 @@ static void test_no_op_with_port_and_start(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
struct sockaddr_in addr;
grpc_tcp_server *s;
GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, &s));
GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, NULL, &s));
LOG_TEST("test_no_op_with_port_and_start");
int port;
@ -225,7 +225,7 @@ static void test_connect(unsigned n) {
unsigned svr1_fd_count;
int svr1_port;
grpc_tcp_server *s;
GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, &s));
GPR_ASSERT(GRPC_ERROR_NONE == grpc_tcp_server_create(NULL, NULL, &s));
unsigned i;
server_weak_ref weak_ref;
server_weak_ref_init(&weak_ref);

@ -112,7 +112,7 @@ void bad_server_thread(void *vargs) {
socklen_t addr_len = sizeof(addr);
int port;
grpc_tcp_server *s;
grpc_error *error = grpc_tcp_server_create(NULL, &s);
grpc_error *error = grpc_tcp_server_create(NULL, NULL, &s);
GPR_ASSERT(error == GRPC_ERROR_NONE);
memset(&addr, 0, sizeof(addr));
addr.ss_family = AF_INET;

@ -49,10 +49,16 @@ void test_unparsable_target(void) {
}
void test_add_same_port_twice() {
grpc_arg a;
a.type = GRPC_ARG_INTEGER;
a.key = GRPC_ARG_ALLOW_REUSEPORT;
a.value.integer = 0;
grpc_channel_args args = {1, &a};
int port = grpc_pick_unused_port_or_die();
char *addr = NULL;
grpc_completion_queue *cq = grpc_completion_queue_create(NULL);
grpc_server *server = grpc_server_create(NULL, NULL);
grpc_server *server = grpc_server_create(&args, NULL);
grpc_server_credentials *fake_creds =
grpc_fake_transport_security_server_credentials_create();
gpr_join_host_port(&addr, "localhost", port);

@ -76,9 +76,15 @@ void test_request_call_on_no_server_cq(void) {
}
void test_bind_server_twice(void) {
grpc_arg a;
a.type = GRPC_ARG_INTEGER;
a.key = GRPC_ARG_ALLOW_REUSEPORT;
a.value.integer = 0;
grpc_channel_args args = {1, &a};
char *addr;
grpc_server *server1 = grpc_server_create(NULL, NULL);
grpc_server *server2 = grpc_server_create(NULL, NULL);
grpc_server *server1 = grpc_server_create(&args, NULL);
grpc_server *server2 = grpc_server_create(&args, NULL);
grpc_completion_queue *cq = grpc_completion_queue_create(NULL);
int port = grpc_pick_unused_port_or_die();
gpr_asprintf(&addr, "[::]:%d", port);

@ -73,7 +73,7 @@ void test_tcp_server_start(test_tcp_server *server, int port) {
memset(&addr.sin_addr, 0, sizeof(addr.sin_addr));
grpc_error *error =
grpc_tcp_server_create(&server->shutdown_complete, &server->tcp_server);
grpc_tcp_server_create(&server->shutdown_complete, NULL, &server->tcp_server);
GPR_ASSERT(error == GRPC_ERROR_NONE);
error = grpc_tcp_server_add_port(server->tcp_server, &addr, sizeof(addr),
&port_added);

Loading…
Cancel
Save