diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-01-02 16:06:51 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-01-02 16:06:51 -0800 |
| commit | 56da51979758dea536ee63febcd0e7d437a4c881 (patch) | |
| tree | 72099e54e61b939f89d26dd6d93fcf57b322d55b /src/supplemental/http | |
| parent | ce681752c44f792feab122cbd846b2407a42da72 (diff) | |
| download | nng-56da51979758dea536ee63febcd0e7d437a4c881.tar.gz nng-56da51979758dea536ee63febcd0e7d437a4c881.tar.bz2 nng-56da51979758dea536ee63febcd0e7d437a4c881.zip | |
Don't hold the lock while stopping HTTP!
Diffstat (limited to 'src/supplemental/http')
| -rw-r--r-- | src/supplemental/http/server.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/supplemental/http/server.c b/src/supplemental/http/server.c index 0f2b1369..64ed9e11 100644 --- a/src/supplemental/http/server.c +++ b/src/supplemental/http/server.c @@ -548,28 +548,30 @@ http_server_acccb(void *arg) http_sconn * sc; int rv; + nni_mtx_lock(&s->mtx); if ((rv = nni_aio_result(aio)) != 0) { - if (rv == NNG_ECLOSED) { - return; + if (!s->closed) { + // try again? + nni_plat_tcp_ep_accept(s->tep, s->accaio); } - // try again? - nni_plat_tcp_ep_accept(s->tep, s->accaio); + nni_mtx_unlock(&s->mtx); return; } tcp = nni_aio_get_pipe(aio); + if (s->closed) { + // If we're closing, then reject this one. + nni_plat_tcp_pipe_fini(tcp); + nni_mtx_unlock(&s->mtx); + return; + } if (http_sconn_init(&sc, s, tcp) != 0) { // The TCP structure is already cleaned up. - + // Start another accept attempt. nni_plat_tcp_ep_accept(s->tep, s->accaio); - return; - } - nni_mtx_lock(&s->mtx); - sc->server = s; - if (s->closed) { nni_mtx_unlock(&s->mtx); - http_sconn_close(sc); return; } + sc->server = s; nni_list_append(&s->conns, sc); nni_http_read_req(sc->http, sc->req, sc->rxaio); @@ -594,8 +596,9 @@ http_server_fini(nni_http_server *s) { http_handler *h; - nni_mtx_lock(&s->mtx); nni_aio_stop(s->accaio); + + nni_mtx_lock(&s->mtx); while (!nni_list_empty(&s->conns)) { nni_cv_wait(&s->cv); } |
