From 835821497a9bbd0d65c20714279c6a2c102016c1 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Wed, 1 Jan 2020 23:00:35 -0800 Subject: fixes #1088 REP protocol does not signal SENDFD properly We've also added some TEST_NNG_SEND_STR and TEST_NNG_RECV_STR to help with convenience when writing test code. --- src/protocol/reqrep0/rep.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/protocol/reqrep0/rep.c') diff --git a/src/protocol/reqrep0/rep.c b/src/protocol/reqrep0/rep.c index 2d00b65f..f8c15fa6 100644 --- a/src/protocol/reqrep0/rep.c +++ b/src/protocol/reqrep0/rep.c @@ -1,5 +1,5 @@ // -// Copyright 2019 Staysail Systems, Inc. +// Copyright 2020 Staysail Systems, Inc. // Copyright 2018 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a @@ -502,6 +502,9 @@ rep0_ctx_recv(void *arg, nni_aio *aio) nni_pollable_clear(s->recvable); } nni_pipe_recv(p->pipe, p->aio_recv); + if ((ctx == s->ctx) && !p->busy) { + nni_pollable_raise(s->sendable); + } len = nni_msg_header_len(msg); memcpy(ctx->btrace, nni_msg_header(msg), len); @@ -583,6 +586,9 @@ rep0_pipe_recv_cb(void *arg) aio = ctx->raio; ctx->raio = NULL; nni_aio_set_msg(p->aio_recv, NULL); + if ((ctx == s->ctx) && !p->busy) { + nni_pollable_raise(s->sendable); + } // schedule another receive nni_pipe_recv(p->pipe, p->aio_recv); @@ -592,13 +598,6 @@ rep0_pipe_recv_cb(void *arg) nni_msg_header_clear(msg); ctx->pipe_id = p->id; - // If we got a request on a pipe that wasn't busy, we should - // mark it sendable. (The sendable flag is not set when there - // is no request needing a reply.) - if ((ctx == s->ctx) && (!p->busy)) { - nni_pollable_raise(s->sendable); - } - nni_mtx_unlock(&s->lk); nni_aio_set_msg(aio, msg); -- cgit v1.2.3-70-g09d2