summaryrefslogtreecommitdiffstats
path: root/src/shared
diff options
context:
space:
mode:
authorSimon Rettberg2016-01-11 12:09:23 +0100
committerSimon Rettberg2016-01-11 12:09:23 +0100
commitd9c2a6cf943ca08f31f61a3fada940f77e3a03d3 (patch)
tree31f627a3d52ff838b046f41516a0fbef0b58b9ee /src/shared
parent[KERNEL/CLIENT] Several minor tweaks and changes (diff)
downloaddnbd3-d9c2a6cf943ca08f31f61a3fada940f77e3a03d3.tar.gz
dnbd3-d9c2a6cf943ca08f31f61a3fada940f77e3a03d3.tar.xz
dnbd3-d9c2a6cf943ca08f31f61a3fada940f77e3a03d3.zip
[SERVER] Fix a lot of (mostly harmless) data races
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/log.c6
-rw-r--r--src/shared/sockhelper.c2
2 files changed, 4 insertions, 4 deletions
diff --git a/src/shared/log.c b/src/shared/log.c
index 6d77dc5..da27392 100644
--- a/src/shared/log.c
+++ b/src/shared/log.c
@@ -82,12 +82,12 @@ void logadd(const logmask_t mask, const char *fmt, ...)
va_list ap;
int ret;
time_t rawtime;
- struct tm *timeinfo;
+ struct tm timeinfo;
char buffer[LINE_LEN];
time( &rawtime );
- timeinfo = localtime( &rawtime );
- size_t offset = strftime( buffer, LINE_LEN, "[%d.%m. %H:%M:%S] ", timeinfo );
+ localtime_r( &rawtime, &timeinfo );
+ size_t offset = strftime( buffer, LINE_LEN, "[%d.%m. %H:%M:%S] ", &timeinfo );
offset += writeLevel( buffer + offset, mask );
va_start( ap, fmt );
ret = vsnprintf( buffer + offset, LINE_LEN - offset, fmt, ap );
diff --git a/src/shared/sockhelper.c b/src/shared/sockhelper.c
index e93d45c..d1dbd8c 100644
--- a/src/shared/sockhelper.c
+++ b/src/shared/sockhelper.c
@@ -207,7 +207,7 @@ int sock_printable(struct sockaddr *addr, socklen_t addrLen, char *output, int l
bool sock_listen(poll_list_t* list, char* bind_addr, uint16_t port)
{
if ( list->count >= MAXLISTEN ) return false;
- struct addrinfo hints, *res, *ptr;
+ struct addrinfo hints, *res = NULL, *ptr;
char portStr[6];
const int on = 1;
int openCount = 0;