From 8ac664fdbab302c9e8cd16a1d45ace5bd00046e5 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 17 Feb 2019 10:17:26 -0800 Subject: fixes #871 panic when sharing rep between threads --- src/protocol/reqrep0/rep.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/protocol/reqrep0/rep.c') diff --git a/src/protocol/reqrep0/rep.c b/src/protocol/reqrep0/rep.c index 5f856f8e..2d00b65f 100644 --- a/src/protocol/reqrep0/rep.c +++ b/src/protocol/reqrep0/rep.c @@ -1,5 +1,5 @@ // -// Copyright 2018 Staysail Systems, Inc. +// Copyright 2019 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a @@ -482,6 +482,14 @@ rep0_ctx_recv(void *arg, nni_aio *aio) nni_aio_finish_error(aio, rv); return; } + if (ctx->raio != NULL) { + // Cannot have a second receive operation pending. + // This could be ESTATE, or we could cancel the first + // with ECANCELED. We elect the former. + nni_mtx_unlock(&s->lk); + nni_aio_finish_error(aio, NNG_ESTATE); + return; + } ctx->raio = aio; nni_list_append(&s->recvq, ctx); nni_mtx_unlock(&s->lk); -- cgit v1.2.3-70-g09d2