From: Adam Dickmeiss Date: Mon, 18 Aug 2014 10:43:25 +0000 (+0200) Subject: Fix hang for 2nd use of target with unresolved DNS PAZ-949 X-Git-Tag: v1.7.2~2 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=374c752c715d2ff4425157634ebcf5cbfdbc32aa;p=pazpar2-moved-to-github.git Fix hang for 2nd use of target with unresolved DNS PAZ-949 --- diff --git a/src/getaddrinfo.c b/src/getaddrinfo.c index 656b9e1..4bce64e 100644 --- a/src/getaddrinfo.c +++ b/src/getaddrinfo.c @@ -61,6 +61,7 @@ struct work { char *ipport; /* result or NULL if it could not be resolved */ struct host *host; /* host that we're dealing with - mother thread */ iochan_man_t iochan_man; /* iochan manager */ + int error; }; static int log_level = YLOG_LOG; @@ -106,6 +107,7 @@ static void perform_getaddrinfo(struct work *w) { yaz_log(YLOG_WARN, "Failed to resolve %s: %s", w->hostport, gai_strerror(error)); + w->error = error; } else { @@ -157,6 +159,7 @@ void iochan_handler(struct iochan *i, int event) { struct work *w = sel_thread_result(p); w->host->ipport = w->ipport; + w->host->error = w->error; connect_resolver_host(w->host, w->iochan_man); xfree(w); } @@ -196,6 +199,7 @@ int host_getaddrinfo(struct host *host, iochan_man_t iochan_man) w->ipport = 0; w->host = host; w->iochan_man = iochan_man; + w->error = 0; #if USE_THREADED_RESOLVER if (use_thread) { @@ -208,6 +212,7 @@ int host_getaddrinfo(struct host *host, iochan_man_t iochan_man) #endif perform_getaddrinfo(w); host->ipport = w->ipport; + host->error = w->error; xfree(w); if (!host->ipport) return -1; diff --git a/src/host.c b/src/host.c index cece235..5c7c15f 100644 --- a/src/host.c +++ b/src/host.c @@ -59,6 +59,7 @@ static struct host *create_host(const char *proxy, host->connections = 0; host->ipport = 0; host->mutex = 0; + host->error = 0; if (host_getaddrinfo(host, iochan_man)) { @@ -121,6 +122,8 @@ struct host *find_host(database_hosts_t hosts, const char *url, hosts->hosts = p; } } + if (p && p->error) /* already resolved error */ + p = 0; yaz_mutex_leave(hosts->mutex); xfree(tproxy); return p; diff --git a/src/host.h b/src/host.h index 7c2144d..7854a22 100644 --- a/src/host.h +++ b/src/host.h @@ -30,6 +30,7 @@ struct host { char *proxy; // logical proxy address char *ipport; // tproxy or proxy resolved struct connection *connections; // All connections to this + int error; // resolving error struct host *next; YAZ_MUTEX mutex; YAZ_COND cond_ready;