summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--PICA_log.c2
-rwxr-xr-xPICA_node.c2
-rw-r--r--PICA_nodewait.c11
3 files changed, 10 insertions, 5 deletions
diff --git a/PICA_log.c b/PICA_log.c
index 3e55381..51fa42f 100644
--- a/PICA_log.c
+++ b/PICA_log.c
@@ -4,6 +4,8 @@
#include <stdlib.h>
#include <time.h>
+//logging functions are not thread-safe, call them only from the main thread
+
static int PICA_loglevel = PICA_LOG_INFO;
void PICA_fatal(const char *fmt,...)
diff --git a/PICA_node.c b/PICA_node.c
index aa0d7c5..d4b98e5 100755
--- a/PICA_node.c
+++ b/PICA_node.c
@@ -2663,6 +2663,7 @@ while(nw)
struct nodelink *nlp;
PICA_debug1("connected to %.255s %u, sending request ", nw->addr.addr, nw->addr.port);
+ PICA_debug2("connection socket is %i", nw->nc.sck);
nlp=nodelink_list_addnew(&nw->nc);
if (nlp)
{
@@ -2682,6 +2683,7 @@ while(nw)
case PICA_NODEWAIT_RESOLVING_FAILED:
{
PICA_debug1("resolving %.255s %u failed: %s", nw->addr.addr, nw->addr.port, gai_strerror(nw->ai_errorcode));
+ PICA_debug2("socket %i is closed", nw->nc.sck);
PICA_nodeaddr_update(nodecfg.nodes_db_file, &nw->addr, 0);
kill_ptr = nw;
}
diff --git a/PICA_nodewait.c b/PICA_nodewait.c
index 6a9a70c..db9df81 100644
--- a/PICA_nodewait.c
+++ b/PICA_nodewait.c
@@ -72,6 +72,9 @@ static DWORD WINAPI nodewait_resolve_thread (void *arg)
static void *nodewait_resolve_thread (void *arg)
#endif
{
+/*
+* DO NOT CALL LOGGING FUNCTIONS HERE, THEY ARE NOT THREAD-SAFE
+*/
struct nodewait *nw = (struct nodewait *)arg;
struct addrinfo h;
char portbuf[8];
@@ -110,6 +113,9 @@ static DWORD WINAPI nodewait_connect_thread (void *arg)
static void *nodewait_connect_thread (void *arg)
#endif
{
+/*
+* DO NOT CALL LOGGING FUNCTIONS HERE, THEY ARE NOT THREAD-SAFE
+*/
struct nodewait *nw = (struct nodewait *)arg;
struct addrinfo *ap;
@@ -126,16 +132,11 @@ while(ap)
continue;
}
- PICA_debug2("created socket %i", nw->nc.sck);
-
if (0 != connect(nw->nc.sck,ap->ai_addr,ap->ai_addrlen))
{
ap=ap->ai_next;
-
- PICA_debug2("connect() failed: %s", strerror(errno));
CLOSE(nw->nc.sck);
- PICA_debug2("closed socket %i", nw->nc.sck);
continue;
}
else