summaryrefslogtreecommitdiff
path: root/src/core/dialer.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-07-31 12:33:58 -0700
committerGarrett D'Amore <garrett@damore.org>2018-08-05 18:45:04 +0300
commitd7f7c896c0ede24249ef63b1e45b1878bf4bd473 (patch)
tree32eece7d91a648f24cb174096fb9667cab978f37 /src/core/dialer.c
parentccc24a8e508131a2226474642a038baaa2cbcc8c (diff)
downloadnng-d7f7c896c0ede24249ef63b1e45b1878bf4bd473.tar.gz
nng-d7f7c896c0ede24249ef63b1e45b1878bf4bd473.tar.bz2
nng-d7f7c896c0ede24249ef63b1e45b1878bf4bd473.zip
fixes #599 nng_dial sync should not return until added to socket
fixes #208 pipe start should occur before connect / accept fixes #616 Race condition closing between header & body This refactors the transports to handle their own connection handshaking before passing the pipe to the socket. This changes and simplifies the setup. This also fixes a rather challenging race condition described by #616.
Diffstat (limited to 'src/core/dialer.c')
-rw-r--r--src/core/dialer.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/core/dialer.c b/src/core/dialer.c
index 34e90891..4b2f105d 100644
--- a/src/core/dialer.c
+++ b/src/core/dialer.c
@@ -232,24 +232,18 @@ dialer_timer_cb(void *arg)
static void
dialer_connect_cb(void *arg)
{
- nni_dialer *d = arg;
- nni_pipe * p;
+ nni_dialer *d = arg;
nni_aio * aio = d->d_con_aio;
int rv;
bool synch;
- if ((rv = nni_aio_result(aio)) == 0) {
- void *data = nni_aio_get_output(aio, 0);
- NNI_ASSERT(data != NULL);
- rv = nni_pipe_create(&p, d->d_sock, d->d_tran, data);
- }
nni_mtx_lock(&d->d_mtx);
synch = d->d_synch;
nni_mtx_unlock(&d->d_mtx);
- switch (rv) {
+ switch ((rv = nni_aio_result(aio))) {
case 0:
- nni_dialer_add_pipe(d, p);
+ nni_dialer_add_pipe(d, nni_aio_get_output(aio, 0));
break;
case NNG_ECLOSED: // No further action.
case NNG_ECANCELED: // No further action.