diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-08-16 09:45:06 +0500 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-08-16 09:45:06 +0500 |
| commit | 1d7594451319b353650c87cb5451c7ed7293cd92 (patch) | |
| tree | 928e5b1454b57048c653cef209aedf6813b3b5d1 /src | |
| parent | 56354bd08cd6549cbaf348cae62f9db01786afc4 (diff) | |
| download | nng-1d7594451319b353650c87cb5451c7ed7293cd92.tar.gz nng-1d7594451319b353650c87cb5451c7ed7293cd92.tar.bz2 nng-1d7594451319b353650c87cb5451c7ed7293cd92.zip | |
fixes #656 Don't connect/remove IPC sockets unless bind fails
Diffstat (limited to 'src')
| -rw-r--r-- | src/platform/posix/posix_ipclisten.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/platform/posix/posix_ipclisten.c b/src/platform/posix/posix_ipclisten.c index 4e33a08f..7134c4e3 100644 --- a/src/platform/posix/posix_ipclisten.c +++ b/src/platform/posix/posix_ipclisten.c @@ -281,15 +281,20 @@ nni_ipc_listener_listen(nni_ipc_listener *l, const nni_sockaddr *sa) return (rv); } - if (((rv = ipc_remove_stale(path)) != 0) || - ((rv = nni_posix_pfd_init(&pfd, fd)) != 0)) { + if ((rv = nni_posix_pfd_init(&pfd, fd)) != 0) { nni_mtx_unlock(&l->mtx); nni_strfree(path); (void) close(fd); return (rv); } - if (bind(fd, (struct sockaddr *) &ss, len) < 0) { + if ((rv = bind(fd, (struct sockaddr *) &ss, len)) != 0) { + if ((errno == EEXIST) || (errno == EADDRINUSE)) { + ipc_remove_stale(path); + rv = bind(fd, (struct sockaddr *) &ss, len); + } + } + if (rv != 0) { rv = nni_plat_errno(errno); nni_mtx_unlock(&l->mtx); nni_strfree(path); |
