diff --git a/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c b/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c index c06d3eb60ae..2bcb295a052 100644 --- a/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c +++ b/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c @@ -152,6 +152,11 @@ error: } port_num = 0; + const char *msg = grpc_error_string(err); + gpr_log(GPR_ERROR, "%s", msg); + grpc_error_free_string(msg); + GRPC_ERROR_UNREF(err); + done: grpc_exec_ctx_finish(&exec_ctx); if (errors != NULL) { @@ -159,7 +164,6 @@ done: GRPC_ERROR_UNREF(errors[i]); } } - GRPC_ERROR_UNREF(err); gpr_free(errors); return port_num; } diff --git a/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c b/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c index 2a50dd4c159..77947b52ab6 100644 --- a/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +++ b/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c @@ -188,7 +188,11 @@ int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr, 3, (server, addr, creds)); /* create security context */ - if (creds == NULL) goto error; + if (creds == NULL) { + err = GRPC_ERROR_CREATE( + "No credentials specified for secure server port (creds==NULL)"); + goto error; + } status = grpc_server_credentials_create_security_connector(creds, &sc); if (status != GRPC_SECURITY_OK) { char *msg; diff --git a/test/core/surface/server_test.c b/test/core/surface/server_test.c index 1e94c5a41b4..e9bc3772d98 100644 --- a/test/core/surface/server_test.c +++ b/test/core/surface/server_test.c @@ -32,9 +32,11 @@ */ #include +#include #include #include #include +#include "src/core/lib/security/credentials/fake/fake_credentials.h" #include "test/core/util/port.h" #include "test/core/util/test_config.h" @@ -86,8 +88,13 @@ void test_bind_server_twice(void) { gpr_asprintf(&addr, "[::]:%d", port); grpc_server_register_completion_queue(server1, cq, NULL); grpc_server_register_completion_queue(server2, cq, NULL); + GPR_ASSERT(0 == grpc_server_add_secure_http2_port(server2, addr, NULL)); GPR_ASSERT(port == grpc_server_add_insecure_http2_port(server1, addr)); GPR_ASSERT(0 == grpc_server_add_insecure_http2_port(server2, addr)); + grpc_server_credentials *fake_creds = + grpc_fake_transport_security_server_credentials_create(); + GPR_ASSERT(0 == grpc_server_add_secure_http2_port(server2, addr, fake_creds)); + grpc_server_credentials_release(fake_creds); grpc_server_shutdown_and_notify(server1, cq, NULL); grpc_server_shutdown_and_notify(server2, cq, NULL); grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL);