diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-12-21 10:55:41 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-12-21 10:55:41 -0800 |
| commit | 5d88c0e80556effb03bc343a1bcd6847500cdac2 (patch) | |
| tree | a2338f39d7be8903f047a1ce7ec153cc9952d0a2 /src/platform/posix/posix_ipcdial.c | |
| parent | 20e625137a38232c87871661c684953ef2cfc5f8 (diff) | |
| download | nng-5d88c0e80556effb03bc343a1bcd6847500cdac2.tar.gz nng-5d88c0e80556effb03bc343a1bcd6847500cdac2.tar.bz2 nng-5d88c0e80556effb03bc343a1bcd6847500cdac2.zip | |
posix: fix for IPC and TCP dialing
The dialer aio needs to be set before starting the dial operation,
as the operation may complete right away.
Diffstat (limited to 'src/platform/posix/posix_ipcdial.c')
| -rw-r--r-- | src/platform/posix/posix_ipcdial.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/platform/posix/posix_ipcdial.c b/src/platform/posix/posix_ipcdial.c index ae98c4f4..25be2e81 100644 --- a/src/platform/posix/posix_ipcdial.c +++ b/src/platform/posix/posix_ipcdial.c @@ -202,6 +202,7 @@ ipc_dialer_dial(void *arg, nni_aio *aio) if ((rv = nni_aio_schedule(aio, ipc_dialer_cancel, d)) != 0) { goto error; } + c->dial_aio = aio; if (connect(fd, (void *) &ss, len) != 0) { if (errno != EINPROGRESS && errno != EAGAIN) { if (errno == ENOENT) { @@ -213,10 +214,10 @@ ipc_dialer_dial(void *arg, nni_aio *aio) goto error; } // Asynchronous connect. - c->dial_aio = aio; if ((rv = nni_posix_pfd_arm(pfd, NNI_POLL_OUT)) != 0) { goto error; } + c->dial_aio = NULL; nni_aio_set_prov_data(aio, c); nni_list_append(&d->connq, aio); nni_mtx_unlock(&d->mtx); @@ -224,6 +225,7 @@ ipc_dialer_dial(void *arg, nni_aio *aio) } // Immediate connect, cool! This probably only happens // on loop back, and probably not on every platform. + c->dial_aio = NULL; nni_aio_set_prov_data(aio, NULL); nni_mtx_unlock(&d->mtx); nni_aio_set_output(aio, 0, c); @@ -231,6 +233,7 @@ ipc_dialer_dial(void *arg, nni_aio *aio) return; error: + c->dial_aio = NULL; nni_aio_set_prov_data(aio, NULL); nni_mtx_unlock(&d->mtx); nng_stream_stop(&c->stream); |
