diff --git a/src/sp/transport/socket/sockfd.c b/src/sp/transport/socket/sockfd.c index b66687b35..82db1163a 100644 --- a/src/sp/transport/socket/sockfd.c +++ b/src/sp/transport/socket/sockfd.c @@ -170,7 +170,10 @@ sfd_tran_pipe_nego_cb(void *arg) int rv; nni_mtx_lock(&ep->mtx); - + if (ep->closed) { + rv = NNG_ECLOSED; + goto error; + } if ((rv = nni_aio_result(aio)) != 0) { goto error; } diff --git a/src/sp/transport/tcp/tcp.c b/src/sp/transport/tcp/tcp.c index c8539c5e3..3ce193c5b 100644 --- a/src/sp/transport/tcp/tcp.c +++ b/src/sp/transport/tcp/tcp.c @@ -174,7 +174,10 @@ tcptran_pipe_nego_cb(void *arg) int rv; nni_mtx_lock(&ep->mtx); - + if (ep->closed) { + rv = NNG_ECLOSED; + goto error; + } if ((rv = nni_aio_result(aio)) != 0) { goto error; } diff --git a/src/sp/transport/tls/tls.c b/src/sp/transport/tls/tls.c index db301af39..c8926c41e 100644 --- a/src/sp/transport/tls/tls.c +++ b/src/sp/transport/tls/tls.c @@ -175,6 +175,10 @@ tlstran_pipe_nego_cb(void *arg) int rv; nni_mtx_lock(&ep->mtx); + if (ep->closed) { + rv = NNG_ECLOSED; + goto error; + } if ((rv = nni_aio_result(aio)) != 0) { goto error; }