Fix up some server setup bugs

pull/6897/head
Craig Tiller 9 years ago
parent a65475c9f3
commit f5f290459a
  1. 6
      src/core/ext/transport/chttp2/server/insecure/server_chttp2.c
  2. 6
      src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c
  3. 7
      test/core/surface/server_test.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;
}

@ -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;

@ -32,9 +32,11 @@
*/
#include <grpc/grpc.h>
#include <grpc/grpc_security.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/string_util.h>
#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);

Loading…
Cancel
Save