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_tcpdial.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_tcpdial.c')
| -rw-r--r-- | src/platform/posix/posix_tcpdial.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/platform/posix/posix_tcpdial.c b/src/platform/posix/posix_tcpdial.c index 442cd824..8a36bba4 100644 --- a/src/platform/posix/posix_tcpdial.c +++ b/src/platform/posix/posix_tcpdial.c @@ -229,6 +229,7 @@ nni_tcp_dial(nni_tcp_dialer *d, const nni_sockaddr *sa, nni_aio *aio) if ((rv = nni_aio_schedule(aio, tcp_dialer_cancel, d)) != 0) { goto error; } + c->dial_aio = aio; if (connect(fd, (void *) &ss, sslen) != 0) { if (errno != EINPROGRESS) { rv = nni_plat_errno(errno); @@ -238,7 +239,6 @@ nni_tcp_dial(nni_tcp_dialer *d, const nni_sockaddr *sa, nni_aio *aio) if ((rv = nni_posix_pfd_arm(&c->pfd, NNI_POLL_OUT)) != 0) { goto error; } - c->dial_aio = aio; nni_aio_set_prov_data(aio, c); nni_list_append(&d->connq, aio); nni_mtx_unlock(&d->mtx); @@ -246,6 +246,7 @@ nni_tcp_dial(nni_tcp_dialer *d, const nni_sockaddr *sa, 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); nd = d->nodelay ? 1 : 0; ka = d->keepalive ? 1 : 0; @@ -256,6 +257,7 @@ nni_tcp_dial(nni_tcp_dialer *d, const nni_sockaddr *sa, nni_aio *aio) return; error: + c->dial_aio = NULL; nni_aio_set_prov_data(aio, NULL); nni_mtx_unlock(&d->mtx); nng_stream_close(&c->stream); |
