diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-04-14 14:29:57 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-04-14 14:29:57 -0700 |
| commit | f31d818c02c95484b7a9c5f8667559bd2524b071 (patch) | |
| tree | 501bf4d7c6f08af8ebd519d848a2f2b624f8a3e9 /src/protocol/survey | |
| parent | 349c1c738c345d6a3930bc5f44cf3e43b2031f54 (diff) | |
| download | nng-f31d818c02c95484b7a9c5f8667559bd2524b071.tar.gz nng-f31d818c02c95484b7a9c5f8667559bd2524b071.tar.bz2 nng-f31d818c02c95484b7a9c5f8667559bd2524b071.zip | |
Pipe ID race on close (pipe IDs are zero at close).
This should address some of the errors we've seen. Additionally,
the scalability test was a bit brittle due to too-short timeouts.
Diffstat (limited to 'src/protocol/survey')
| -rw-r--r-- | src/protocol/survey/respond.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/protocol/survey/respond.c b/src/protocol/survey/respond.c index 8fe12e19..8e36cbb0 100644 --- a/src/protocol/survey/respond.c +++ b/src/protocol/survey/respond.c @@ -43,6 +43,7 @@ struct nni_resp_sock { struct nni_resp_pipe { nni_pipe * npipe; nni_resp_sock * psock; + uint32_t id; nni_msgq * sendq; nni_aio aio_getq; nni_aio aio_putq; @@ -180,7 +181,11 @@ nni_resp_pipe_start(void *arg) nni_resp_sock *psock = ppipe->psock; int rv; - rv = nni_idhash_insert(&psock->pipes, nni_pipe_id(ppipe->npipe), ppipe); + ppipe->id = nni_pipe_id(ppipe->npipe); + rv = nni_idhash_insert(&psock->pipes, ppipe->id, ppipe); + if (rv != 0) { + return (rv); + } nni_pipe_incref(ppipe->npipe); nni_pipe_aio_recv(ppipe->npipe, &ppipe->aio_recv); @@ -200,7 +205,7 @@ nni_resp_pipe_stop(void *arg) if (ppipe->running) { ppipe->running = 0; - nni_idhash_remove(&psock->pipes, nni_pipe_id(ppipe->npipe)); + nni_idhash_remove(&psock->pipes, ppipe->id); nni_msgq_close(ppipe->sendq); nni_msgq_aio_cancel(psock->urq, &ppipe->aio_putq); @@ -300,7 +305,6 @@ nni_resp_recv_cb(void *arg) nni_msgq *urq = nni_sock_recvq(psock->nsock); nni_msg *msg; uint8_t idbuf[4]; - uint32_t id; int hops; int rv; @@ -308,8 +312,7 @@ nni_resp_recv_cb(void *arg) goto error; } - id = nni_pipe_id(ppipe->npipe); - NNI_PUT32(idbuf, id); + NNI_PUT32(idbuf, ppipe->id); msg = ppipe->aio_recv.a_msg; ppipe->aio_recv.a_msg = NULL; |
