aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2015-08-05 07:16:03 -0700
committerGravatar Craig Tiller <ctiller@google.com>2015-08-05 07:16:03 -0700
commitc436a801699af7a013e02f2fb06235f1e21c87f6 (patch)
treeaa8b263080e52f5965fb6413813d58e92a72377f /src/core
parent08dda265c41b42d46be899c2444e7e03a02b2958 (diff)
parent80aecf609b54aeb0677461cae771362b5affe173 (diff)
Merge github.com:grpc/grpc into primary-goat-whisperer
Diffstat (limited to 'src/core')
-rw-r--r--src/core/iomgr/sockaddr_utils.c5
-rw-r--r--src/core/iomgr/tcp_server_windows.c29
-rw-r--r--src/core/surface/channel.c4
3 files changed, 29 insertions, 9 deletions
diff --git a/src/core/iomgr/sockaddr_utils.c b/src/core/iomgr/sockaddr_utils.c
index 71ac12e87b..65ec1f94ac 100644
--- a/src/core/iomgr/sockaddr_utils.c
+++ b/src/core/iomgr/sockaddr_utils.c
@@ -170,6 +170,11 @@ int grpc_sockaddr_to_string(char **out, const struct sockaddr *addr,
char *grpc_sockaddr_to_uri(const struct sockaddr *addr) {
char *temp;
char *result;
+ struct sockaddr_in addr_normalized;
+
+ if (grpc_sockaddr_is_v4mapped(addr, &addr_normalized)) {
+ addr = (const struct sockaddr *)&addr_normalized;
+ }
switch (addr->sa_family) {
case AF_INET:
diff --git a/src/core/iomgr/tcp_server_windows.c b/src/core/iomgr/tcp_server_windows.c
index bcd2aa8536..0adbe9507c 100644
--- a/src/core/iomgr/tcp_server_windows.c
+++ b/src/core/iomgr/tcp_server_windows.c
@@ -186,6 +186,17 @@ error:
return -1;
}
+static void decrement_active_ports_and_notify(server_port *sp) {
+ sp->shutting_down = 0;
+ sp->socket->read_info.outstanding = 0;
+ gpr_mu_lock(&sp->server->mu);
+ GPR_ASSERT(sp->server->active_ports > 0);
+ if (0 == --sp->server->active_ports) {
+ gpr_cv_broadcast(&sp->server->cv);
+ }
+ gpr_mu_unlock(&sp->server->mu);
+}
+
/* start_accept will reference that for the IOCP notification request. */
static void on_accept(void *arg, int from_iocp);
@@ -234,6 +245,15 @@ static void start_accept(server_port *port) {
return;
failure:
+ if (port->shutting_down) {
+ /* We are abandoning the listener port, take that into account to prevent
+ occasional hangs on shutdown. The hang happens when sp->shutting_down
+ change is not seen by on_accept and we proceed to trying new accept,
+ but we fail there because the listening port has been closed in the
+ meantime. */
+ decrement_active_ports_and_notify(port);
+ return;
+ }
utf8_message = gpr_format_message(WSAGetLastError());
gpr_log(GPR_ERROR, message, utf8_message);
gpr_free(utf8_message);
@@ -277,14 +297,7 @@ static void on_accept(void *arg, int from_iocp) {
if (sp->shutting_down) {
/* During the shutdown case, we ARE expecting an error. So that's well,
and we can wake up the shutdown thread. */
- sp->shutting_down = 0;
- sp->socket->read_info.outstanding = 0;
- gpr_mu_lock(&sp->server->mu);
- GPR_ASSERT(sp->server->active_ports > 0);
- if (0 == --sp->server->active_ports) {
- gpr_cv_broadcast(&sp->server->cv);
- }
- gpr_mu_unlock(&sp->server->mu);
+ decrement_active_ports_and_notify(sp);
return;
} else {
char *utf8_message = gpr_format_message(WSAGetLastError());
diff --git a/src/core/surface/channel.c b/src/core/surface/channel.c
index 81f673f856..688a586e18 100644
--- a/src/core/surface/channel.c
+++ b/src/core/surface/channel.c
@@ -229,7 +229,9 @@ static void destroy_channel(void *p, int ok) {
registered_call *rc = channel->registered_calls;
channel->registered_calls = rc->next;
GRPC_MDELEM_UNREF(rc->path);
- GRPC_MDELEM_UNREF(rc->authority);
+ if (rc->authority) {
+ GRPC_MDELEM_UNREF(rc->authority);
+ }
gpr_free(rc);
}
grpc_mdctx_unref(channel->metadata_context);