diff options
| author | Garrett D'Amore <garrett@damore.org> | 2016-12-25 18:08:44 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2016-12-25 18:08:44 -0800 |
| commit | 0cd2fa7310f1fdf45443a8a9e3335658b1c3c64c (patch) | |
| tree | 1098c7f4976033bb311b45c378079700c9330b62 /src/platform | |
| parent | 64de60d98e8e4a896f9d13e4aa70343f329d88b4 (diff) | |
| download | nng-0cd2fa7310f1fdf45443a8a9e3335658b1c3c64c.tar.gz nng-0cd2fa7310f1fdf45443a8a9e3335658b1c3c64c.tar.bz2 nng-0cd2fa7310f1fdf45443a8a9e3335658b1c3c64c.zip | |
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.)
Diffstat (limited to 'src/platform')
| -rw-r--r-- | src/platform/posix/posix_alloc.c | 2 | ||||
| -rw-r--r-- | src/platform/posix/posix_synch.c | 6 | ||||
| -rw-r--r-- | src/platform/posix/posix_thread.c | 2 |
3 files changed, 6 insertions, 4 deletions
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)); } |
