Brought grpc_server_add_secure_http2_port in line with grpc_server_http2_port

pull/149/head
murgatroid99 10 years ago
parent 9e14ead3f6
commit c896e192f7
  1. 3
      include/grpc/grpc.h
  2. 16
      src/core/security/server_secure_chttp2.c

@ -428,7 +428,8 @@ grpc_server *grpc_server_create(grpc_completion_queue *cq,
REQUIRES: server not started */ REQUIRES: server not started */
int grpc_server_add_http2_port(grpc_server *server, const char *addr); int grpc_server_add_http2_port(grpc_server *server, const char *addr);
/* Add a secure port to server; returns 1 on success, 0 on failure /* Add a secure port to server.
Returns bound port number on success, 0 on failure.
REQUIRES: server not started */ REQUIRES: server not started */
int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr); int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr);

@ -93,6 +93,8 @@ int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr) {
grpc_tcp_server *tcp = NULL; grpc_tcp_server *tcp = NULL;
size_t i; size_t i;
int count = 0; int count = 0;
int port_num = -1;
int port_temp;
resolved = grpc_blocking_resolve_address(addr, "https"); resolved = grpc_blocking_resolve_address(addr, "https");
if (!resolved) { if (!resolved) {
@ -105,9 +107,15 @@ int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr) {
} }
for (i = 0; i < resolved->naddrs; i++) { for (i = 0; i < resolved->naddrs; i++) {
if (grpc_tcp_server_add_port(tcp, port_temp = grpc_tcp_server_add_port(
(struct sockaddr *)&resolved->addrs[i].addr, tcp, (struct sockaddr *)&resolved->addrs[i].addr,
resolved->addrs[i].len)) { resolved->addrs[i].len);
if (port_temp >= 0) {
if (port_num == -1) {
port_num = port_temp;
} else {
GPR_ASSERT(port_num == port_temp);
}
count++; count++;
} }
} }
@ -125,7 +133,7 @@ int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr) {
/* Register with the server only upon success */ /* Register with the server only upon success */
grpc_server_add_listener(server, tcp, start, destroy); grpc_server_add_listener(server, tcp, start, destroy);
return 1; return port_num;
/* Error path: cleanup and return */ /* Error path: cleanup and return */
error: error:

Loading…
Cancel
Save