aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/supplemental/http/http_server.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/supplemental/http/http_server.c b/src/supplemental/http/http_server.c
index 1ebc8907..7f6f9abe 100644
--- a/src/supplemental/http/http_server.c
+++ b/src/supplemental/http/http_server.c
@@ -751,14 +751,16 @@ finish:
nni_aio_set_input(sc->cbaio, 1, h);
nni_aio_set_input(sc->cbaio, 2, sc->conn);
+ // Set a reference -- this because the callback may be running
+ // asynchronously even after it gets removed from the server.
+ nni_atomic_inc64(&h->ref);
+
// Documented that we call this on behalf of the callback.
if (nni_aio_begin(sc->cbaio) != 0) {
nni_mtx_unlock(&s->mtx);
return;
}
- // Set a reference -- this because the callback may be running
- // asynchronously even after it gets removed from the server.
- nni_atomic_inc64(&h->ref);
+
nni_mtx_unlock(&s->mtx);
h->cb(sc->cbaio);
}