From 0cd2fa7310f1fdf45443a8a9e3335658b1c3c64c Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 25 Dec 2016 18:08:44 -0800 Subject: Substantial fixes for listen & dialers. At this point listening and dialing operations appear to function properly. As part of this I had to break the close logic up since otherwise we had a loop trying to reap a thread from itself. So there is now a separate reaper thread for pipes per-socket. I also changed lists to be a bit more rigid, and allocations now zero memory initially. (We had bugs due to uninitialized memory, and rather than hunt them all down, lets just init them to sane zero values.) --- src/platform/posix/posix_alloc.c | 2 +- src/platform/posix/posix_synch.c | 6 ++++-- src/platform/posix/posix_thread.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/platform') diff --git a/src/platform/posix/posix_alloc.c b/src/platform/posix/posix_alloc.c index 83fe305d..98a76669 100644 --- a/src/platform/posix/posix_alloc.c +++ b/src/platform/posix/posix_alloc.c @@ -17,7 +17,7 @@ void * nni_alloc(size_t size) { - return (malloc(size)); + return (calloc(1, size)); } diff --git a/src/platform/posix/posix_synch.c b/src/platform/posix/posix_synch.c index 2fb92915..0526eb7c 100644 --- a/src/platform/posix/posix_synch.c +++ b/src/platform/posix/posix_synch.c @@ -45,8 +45,10 @@ nni_mutex_fini(nni_mutex *mp) void nni_mutex_enter(nni_mutex *m) { - if (pthread_mutex_lock(&m->mx) != 0) { - nni_panic("pthread_mutex_lock failed"); + int rv; + + if ((rv = pthread_mutex_lock(&m->mx)) != 0) { + nni_panic("pthread_mutex_lock failed: %s", strerror(rv)); } } diff --git a/src/platform/posix/posix_thread.c b/src/platform/posix/posix_thread.c index 3fd9bfe7..f5cad7a9 100644 --- a/src/platform/posix/posix_thread.c +++ b/src/platform/posix/posix_thread.c @@ -80,7 +80,7 @@ nni_thread_reap(nni_thread *thr) int rv; if ((rv = pthread_join(thr->tid, NULL)) != 0) { - nni_panic("pthread_thread: %s", strerror(errno)); + nni_panic("pthread_thread: %s", strerror(rv)); } nni_free(thr, sizeof (*thr)); } -- cgit v1.2.3-70-g09d2