From b4f5889a3a939c9b1320c5d884a3830db9c3b224 Mon Sep 17 00:00:00 2001 From: Mark Riddoch Date: Wed, 3 Jul 2013 18:15:02 +0200 Subject: [PATCH] Fix in poll.c to prevent further processing when an error makes a DCBV into a zombie Fix in laod_config for issues when not being able to load router modules --- core/config.c | 4 ++-- core/dcb.c | 6 ++++-- core/poll.c | 6 ++++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/core/config.c b/core/config.c index 7e56baaf2..524d27fd6 100644 --- a/core/config.c +++ b/core/config.c @@ -176,7 +176,7 @@ CONFIG_CONTEXT *obj; { char *servers = config_get_value(obj->parameters, "servers"); char *roptions = config_get_value(obj->parameters, "router_options"); - if (servers) + if (servers && obj->element) { char *s = strtok(servers, ","); while (s) @@ -191,7 +191,7 @@ CONFIG_CONTEXT *obj; s = strtok(NULL, ","); } } - if (roptions) + if (roptions && obj->element) { char *s = strtok(roptions, ","); while (s) diff --git a/core/dcb.c b/core/dcb.c index 51fbef92b..59d5aa7d0 100644 --- a/core/dcb.c +++ b/core/dcb.c @@ -258,7 +258,8 @@ GWPROTOCOL *funcs; } if ((funcs = (GWPROTOCOL *)load_module(protocol, MODULE_PROTOCOL)) == NULL) { - dcb_free(dcb); + dcb_final_free(dcb); + fprintf(stderr, "Failed to load protocol module for %s, feee dcb %p\n", protocol, dcb); return NULL; } memcpy(&(dcb->func), funcs, sizeof(GWPROTOCOL)); @@ -266,7 +267,8 @@ GWPROTOCOL *funcs; if ((dcb->fd = dcb->func.connect(dcb, server, session)) == -1) { - dcb_free(dcb); + dcb_final_free(dcb); + fprintf(stderr, "Failed to connect to server, feee dcb %p\n", dcb); return NULL; } atomic_add(&server->stats.n_connections, 1); diff --git a/core/poll.c b/core/poll.c index 32154c239..b911176c7 100644 --- a/core/poll.c +++ b/core/poll.c @@ -141,6 +141,7 @@ struct epoll_event events[MAX_EVENTS]; int i, nfds; int thread_id = (int)arg; + /* Add this thread to the bitmask of running polling threads */ bitmask_set(&poll_mask, thread_id); while (1) { @@ -174,11 +175,15 @@ int thread_id = (int)arg; { atomic_add(&pollStats.n_error, 1); dcb->func.error(dcb); + if (DCB_ISZOMBIE(dcb)) + continue; } if (ev & EPOLLHUP) { atomic_add(&pollStats.n_hup, 1); dcb->func.hangup(dcb); + if (DCB_ISZOMBIE(dcb)) + continue; } if (ev & EPOLLOUT) { @@ -203,6 +208,7 @@ int thread_id = (int)arg; dcb_process_zombies(thread_id); if (shutdown) { + /* Remove this thread from the bitmask of running polling threads */ bitmask_clear(&poll_mask, thread_id); return; }