summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorme_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac>2013-08-07 21:07:48 +0000
committerme_desk <me_desk@fb96df88-216d-11de-830c-f3023f12d8ac>2013-08-07 21:07:48 +0000
commit14af4d5f8b4b59f463d4250fa1c2600e82d22fbe (patch)
treec50470e61a44fa66cc5316a5086372525f2b8b88
parentb93999b60412e6cefe950ae7d714db07f6f44760 (diff)
downloadpica-pica-14af4d5f8b4b59f463d4250fa1c2600e82d22fbe.tar.gz
pica-pica-14af4d5f8b4b59f463d4250fa1c2600e82d22fbe.zip
bugfix: race condition, sometimes nodewait_start_connect() was called several times for the same entry from main thread before nodewait state was updated in started thread
git-svn-id: svn://localhost/project_picapica/trunk@261 fb96df88-216d-11de-830c-f3023f12d8ac
-rw-r--r--PICA_nodewait.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/PICA_nodewait.c b/PICA_nodewait.c
index db9df81..c3479b7 100644
--- a/PICA_nodewait.c
+++ b/PICA_nodewait.c
@@ -79,7 +79,6 @@ struct nodewait *nw = (struct nodewait *)arg;
struct addrinfo h;
char portbuf[8];
-nw->state = PICA_NODEWAIT_RESOLVING;
memset(&h,0,sizeof(struct addrinfo));
@@ -119,7 +118,6 @@ static void *nodewait_connect_thread (void *arg)
struct nodewait *nw = (struct nodewait *)arg;
struct addrinfo *ap;
-nw->state = PICA_NODEWAIT_CONNECTING;
ap = nw->ai;
@@ -177,6 +175,8 @@ nw ->addr = *a;
PICA_debug1("starting to resolve node address %.255s %u ...", nw->addr.addr, nw->addr.port);
+nw->state = PICA_NODEWAIT_RESOLVING;
+
#ifndef WIN32
if (0 != pthread_attr_init(&attr))
PICA_error("pthread_attr_init() call failed.");
@@ -209,6 +209,7 @@ HANDLE thread_h;
PICA_debug1("connecting to node %.255s %u ...", nw->addr.addr, nw->addr.port);
+nw->state = PICA_NODEWAIT_CONNECTING;
#ifndef WIN32
if (0 != pthread_attr_init(&attr))
PICA_error("pthread_attr_init() call failed.");