aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-07-15 16:50:49 -0700
committerGarrett D'Amore <garrett@damore.org>2017-07-15 16:50:49 -0700
commit0d48c9d4f359ec79f9cc10db3e0e04cb7a58623e (patch)
treef1b0dd28372a92d756e6cd42eb949829d007a591 /src/transport
parent7f95fde8d752dd93c20ff0a209334f4aec549111 (diff)
downloadnng-0d48c9d4f359ec79f9cc10db3e0e04cb7a58623e.tar.gz
nng-0d48c9d4f359ec79f9cc10db3e0e04cb7a58623e.tar.bz2
nng-0d48c9d4f359ec79f9cc10db3e0e04cb7a58623e.zip
Race conditions removed... TCP tests work well know.
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/tcp/tcp.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/transport/tcp/tcp.c b/src/transport/tcp/tcp.c
index 875eb71a..dad4c46e 100644
--- a/src/transport/tcp/tcp.c
+++ b/src/transport/tcp/tcp.c
@@ -1,5 +1,6 @@
//
// Copyright 2017 Garrett D'Amore <garrett@damore.org>
+// Copyright 2017 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
@@ -141,11 +142,10 @@ nni_tcp_cancel_nego(nni_aio *aio)
nni_tcp_pipe *pipe = aio->a_prov_data;
nni_mtx_lock(&pipe->mtx);
- if ((aio = pipe->user_negaio) != NULL) {
- pipe->user_negaio = NULL;
- nni_aio_stop(aio);
- }
+ pipe->user_negaio = NULL;
nni_mtx_unlock(&pipe->mtx);
+
+ nni_aio_cancel(&pipe->negaio, aio->a_result);
}
static void
@@ -311,8 +311,8 @@ nni_tcp_cancel_tx(nni_aio *aio)
pipe->user_txaio = NULL;
nni_mtx_unlock(&pipe->mtx);
- // stop the underlying aio ... we don't want a result for it.
- nni_aio_stop(&pipe->txaio);
+ // cancel the underlying operation.
+ nni_aio_cancel(&pipe->txaio, aio->a_result);
}
static void
@@ -356,8 +356,8 @@ nni_tcp_cancel_rx(nni_aio *aio)
pipe->user_rxaio = NULL;
nni_mtx_unlock(&pipe->mtx);
- // stop the underlying aio ... we don't want a result for it.
- nni_aio_stop(&pipe->rxaio);
+ // cancel the underlying operation.
+ nni_aio_cancel(&pipe->rxaio, aio->a_result);
}
static void
@@ -637,11 +637,10 @@ nni_tcp_cancel_ep(nni_aio *aio)
nni_tcp_ep *ep = aio->a_prov_data;
nni_mtx_lock(&ep->mtx);
- if (ep->user_aio == aio) {
- ep->user_aio = NULL;
- }
- nni_aio_stop(&ep->aio);
+ ep->user_aio = NULL;
nni_mtx_unlock(&ep->mtx);
+
+ nni_aio_cancel(&ep->aio, aio->a_result);
}
static void