From e2a8348c76a46cda8b847bacd8af589ec549e47c Mon Sep 17 00:00:00 2001 From: Jan Wieck Date: Fri, 14 Dec 2012 15:01:31 -0500 Subject: [PATCH] Fix for bug273 Do not force the event provider to be part of the providers unless we don't find any provider at all otherwise. --- src/slon/remote_worker.c | 66 ++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 37 deletions(-) diff --git a/src/slon/remote_worker.c b/src/slon/remote_worker.c index 69de8254..bc3e42d7 100644 --- a/src/slon/remote_worker.c +++ b/src/slon/remote_worker.c @@ -1684,7 +1684,7 @@ adjust_provider_info(SlonNode * node, WorkerGroupData * wd, int cleanup, * If the list of currently replicated sets we receive from this * provider is empty, we don't need to maintain a connection to it. */ - if (provider->set_head == NULL && provider->no_id != event_provider) + if (provider->set_head == NULL) { /* * Tell this helper thread to exit, join him and destroy thread @@ -1750,47 +1750,39 @@ adjust_provider_info(SlonNode * node, WorkerGroupData * wd, int cleanup, /* * Step 4. * - * Make sure the event provider is in the list of providers. + * If we don't have ANY provider at this point, fall back + * on the node that we got this event from. */ - if (event_provider >= 0) + if (event_provider >= 0 && wd->provider_head == NULL) { - for (provider = wd->provider_head; provider; - provider = provider->next) - { - if (provider->no_id == event_provider) - break; - } - if (provider == NULL) - { - /* - * No provider entry found. Create a new one. - */ - provider = (ProviderInfo *) - malloc(sizeof(ProviderInfo)); - memset(provider, 0, sizeof(ProviderInfo)); - provider->no_id = event_provider; - provider->wd = wd; + /* + * No provider entry found. Create a new one. + */ + provider = (ProviderInfo *) + malloc(sizeof(ProviderInfo)); + memset(provider, 0, sizeof(ProviderInfo)); + provider->no_id = event_provider; + provider->wd = wd; - dstring_init(&provider->helper_query); + dstring_init(&provider->helper_query); - /* - * Add the provider to our work group - */ - DLLIST_ADD_TAIL(wd->provider_head, wd->provider_tail, - provider); + /* + * Add the provider to our work group + */ + DLLIST_ADD_TAIL(wd->provider_head, wd->provider_tail, + provider); - /* - * Copy the runtime configurations conninfo into the provider - * info. - */ - rtcfg_node = rtcfg_findNode(provider->no_id); - if (rtcfg_node != NULL) - { - provider->pa_connretry = rtcfg_node->pa_connretry; - if (rtcfg_node->pa_conninfo != NULL) - provider->pa_conninfo = - strdup(rtcfg_node->pa_conninfo); - } + /* + * Copy the runtime configurations conninfo into the provider + * info. + */ + rtcfg_node = rtcfg_findNode(provider->no_id); + if (rtcfg_node != NULL) + { + provider->pa_connretry = rtcfg_node->pa_connretry; + if (rtcfg_node->pa_conninfo != NULL) + provider->pa_conninfo = + strdup(rtcfg_node->pa_conninfo); } } } -- 2.39.5