From 14af4d5f8b4b59f463d4250fa1c2600e82d22fbe Mon Sep 17 00:00:00 2001 From: me_desk Date: Wed, 7 Aug 2013 21:07:48 +0000 Subject: 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 --- PICA_nodewait.c | 5 +++-- 1 file 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."); -- cgit v1.2.1