diff options
| author | Garrett D'Amore <garrett@damore.org> | 2021-12-31 14:13:08 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2021-12-31 16:11:25 -0800 |
| commit | 5e06e98541ff223e7a18b6a61120532acd09d410 (patch) | |
| tree | 73d3b17ae7676a1e730e190d29f9e2661959b6a2 | |
| parent | 2f66b99830e6dc731e4f631ea743771df701659e (diff) | |
| download | nng-5e06e98541ff223e7a18b6a61120532acd09d410.tar.gz nng-5e06e98541ff223e7a18b6a61120532acd09d410.tar.bz2 nng-5e06e98541ff223e7a18b6a61120532acd09d410.zip | |
Replace nni_aio_prov_set_extra with nni_aio_prov_set_data.
This takes one less parameter, and is simpler. It will let us
reclaim the aio_prov_extra data space as well, so that we can
use it for other purposes.
| -rw-r--r-- | src/core/aio.c | 8 | ||||
| -rw-r--r-- | src/core/aio.h | 9 | ||||
| -rw-r--r-- | src/platform/posix/posix_ipcdial.c | 18 | ||||
| -rw-r--r-- | src/platform/posix/posix_resolv_gai.c | 10 | ||||
| -rw-r--r-- | src/platform/posix/posix_tcpdial.c | 20 | ||||
| -rw-r--r-- | src/platform/windows/win_resolv.c | 10 | ||||
| -rw-r--r-- | src/platform/windows/win_tcpdial.c | 8 | ||||
| -rw-r--r-- | src/platform/windows/win_tcplisten.c | 12 | ||||
| -rw-r--r-- | src/supplemental/http/http_conn.c | 99 | ||||
| -rw-r--r-- | src/supplemental/websocket/websocket.c | 4 |
10 files changed, 91 insertions, 107 deletions
diff --git a/src/core/aio.c b/src/core/aio.c index 9d6c904b..65d8b984 100644 --- a/src/core/aio.c +++ b/src/core/aio.c @@ -618,15 +618,15 @@ nni_aio_expire_loop(void *arg) } void * -nni_aio_get_prov_extra(nni_aio *aio, unsigned index) +nni_aio_get_prov_data(nni_aio *aio) { - return (aio->a_prov_extra[index]); + return (aio->a_prov_data); } void -nni_aio_set_prov_extra(nni_aio *aio, unsigned index, void *data) +nni_aio_set_prov_data(nni_aio *aio, void *data) { - aio->a_prov_extra[index] = data; + aio->a_prov_data = data; } void diff --git a/src/core/aio.h b/src/core/aio.h index 9ef5f63d..d1d4cf79 100644 --- a/src/core/aio.h +++ b/src/core/aio.h @@ -133,8 +133,8 @@ extern void nni_aio_abort(nni_aio *, int rv); // nng_aio_finish family of functions.) extern int nni_aio_begin(nni_aio *); -extern void *nni_aio_get_prov_extra(nni_aio *, unsigned); -extern void nni_aio_set_prov_extra(nni_aio *, unsigned, void *); +extern void *nni_aio_get_prov_data(nni_aio *); +extern void nni_aio_set_prov_data(nni_aio *, void *); // nni_aio_advance_iov moves up the iov, reflecting that some I/O as // been performed. It returns the amount of data remaining in the argument; // i.e. if the count refers to more data than the iov can support, then @@ -200,9 +200,8 @@ struct nng_aio { // Provider-use fields. nni_aio_cancel_fn a_cancel_fn; void *a_cancel_arg; - nni_list_node a_prov_node; // Linkage on provider list. - void *a_prov_extra[2]; // Extra data used by provider - + void *a_prov_data; + nni_list_node a_prov_node; // Linkage on provider list. nni_aio_expire_q *a_expire_q; nni_list_node a_expire_node; // Expiration node nni_reap_node a_reap_node; diff --git a/src/platform/posix/posix_ipcdial.c b/src/platform/posix/posix_ipcdial.c index 69ed4f77..464179a0 100644 --- a/src/platform/posix/posix_ipcdial.c +++ b/src/platform/posix/posix_ipcdial.c @@ -37,9 +37,9 @@ ipc_dialer_close(void *arg) while ((aio = nni_list_first(&d->connq)) != NULL) { nni_ipc_conn *c; nni_list_remove(&d->connq, aio); - if ((c = nni_aio_get_prov_extra(aio, 0)) != NULL) { + if ((c = nni_aio_get_prov_data(aio)) != NULL) { c->dial_aio = NULL; - nni_aio_set_prov_extra(aio, 0, NULL); + nni_aio_set_prov_data(aio, NULL); nng_stream_close(&c->stream); nng_stream_free(&c->stream); } @@ -84,13 +84,13 @@ ipc_dialer_cancel(nni_aio *aio, void *arg, int rv) nni_mtx_lock(&d->mtx); if ((!nni_aio_list_active(aio)) || - ((c = nni_aio_get_prov_extra(aio, 0)) == NULL)) { + ((c = nni_aio_get_prov_data(aio)) == NULL)) { nni_mtx_unlock(&d->mtx); return; } nni_aio_list_remove(aio); c->dial_aio = NULL; - nni_aio_set_prov_extra(aio, 0, NULL); + nni_aio_set_prov_data(aio, NULL); nni_mtx_unlock(&d->mtx); nni_aio_finish_error(aio, rv); @@ -133,7 +133,7 @@ ipc_dialer_cb(nni_posix_pfd *pfd, unsigned ev, void *arg) c->dial_aio = NULL; nni_aio_list_remove(aio); - nni_aio_set_prov_extra(aio, 0, NULL); + nni_aio_set_prov_data(aio, NULL); nni_mtx_unlock(&d->mtx); if (rv != 0) { @@ -217,14 +217,14 @@ ipc_dialer_dial(void *arg, nni_aio *aio) goto error; } c->dial_aio = aio; - nni_aio_set_prov_extra(aio, 0, c); + nni_aio_set_prov_data(aio, c); nni_list_append(&d->connq, aio); nni_mtx_unlock(&d->mtx); return; } // Immediate connect, cool! This probably only happens - // on loopback, and probably not on every platform. - nni_aio_set_prov_extra(aio, 0, NULL); + // on loop back, and probably not on every platform. + nni_aio_set_prov_data(aio, NULL); nni_mtx_unlock(&d->mtx); nni_posix_ipc_start(c); nni_aio_set_output(aio, 0, c); @@ -232,7 +232,7 @@ ipc_dialer_dial(void *arg, nni_aio *aio) return; error: - nni_aio_set_prov_extra(aio, 0, NULL); + nni_aio_set_prov_data(aio, NULL); nni_mtx_unlock(&d->mtx); nng_stream_free(&c->stream); nni_aio_finish_error(aio, rv); diff --git a/src/platform/posix/posix_resolv_gai.c b/src/platform/posix/posix_resolv_gai.c index aa6547a5..1c209f1f 100644 --- a/src/platform/posix/posix_resolv_gai.c +++ b/src/platform/posix/posix_resolv_gai.c @@ -63,12 +63,12 @@ resolv_cancel(nni_aio *aio, void *arg, int rv) resolv_item *item = arg; nni_mtx_lock(&resolv_mtx); - if (item != nni_aio_get_prov_extra(aio, 0)) { + if (item != nni_aio_get_prov_data(aio)) { // Already canceled? nni_mtx_unlock(&resolv_mtx); return; } - nni_aio_set_prov_extra(aio, 0, NULL); + nni_aio_set_prov_data(aio, NULL); if (nni_aio_list_active(aio)) { // We have not been picked up by a resolver thread yet, // so we can just discard everything. @@ -277,7 +277,7 @@ nni_resolv_ip(const char *host, const char *serv, int af, bool passive, if (resolv_fini) { rv = NNG_ECLOSED; } else { - nni_aio_set_prov_extra(aio, 0, item); + nni_aio_set_prov_data(aio, item); rv = nni_aio_schedule(aio, resolv_cancel, item); } if (rv != 0) { @@ -313,7 +313,7 @@ resolv_worker(void *unused) continue; } - item = nni_aio_get_prov_extra(aio, 0); + item = nni_aio_get_prov_data(aio); nni_aio_list_remove(aio); // Now attempt to do the work. This runs synchronously. @@ -324,7 +324,7 @@ resolv_worker(void *unused) // Check to make sure we were not canceled. if ((aio = item->aio) != NULL) { - nni_aio_set_prov_extra(aio, 0, NULL); + nni_aio_set_prov_data(aio, NULL); item->aio = NULL; item->sa = NULL; diff --git a/src/platform/posix/posix_tcpdial.c b/src/platform/posix/posix_tcpdial.c index f7568db3..d9b58210 100644 --- a/src/platform/posix/posix_tcpdial.c +++ b/src/platform/posix/posix_tcpdial.c @@ -1,5 +1,5 @@ // -// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // Copyright 2018 Devolutions <info@devolutions.net> // @@ -52,9 +52,9 @@ nni_tcp_dialer_close(nni_tcp_dialer *d) while ((aio = nni_list_first(&d->connq)) != NULL) { nni_tcp_conn *c; nni_list_remove(&d->connq, aio); - if ((c = nni_aio_get_prov_extra(aio, 0)) != NULL) { + if ((c = nni_aio_get_prov_data(aio)) != NULL) { c->dial_aio = NULL; - nni_aio_set_prov_extra(aio, 0, NULL); + nni_aio_set_prov_data(aio, NULL); nng_stream_close(&c->stream); nng_stream_free(&c->stream); } @@ -97,13 +97,13 @@ tcp_dialer_cancel(nni_aio *aio, void *arg, int rv) nni_mtx_lock(&d->mtx); if ((!nni_aio_list_active(aio)) || - ((c = nni_aio_get_prov_extra(aio, 0)) == NULL)) { + ((c = nni_aio_get_prov_data(aio)) == NULL)) { nni_mtx_unlock(&d->mtx); return; } nni_aio_list_remove(aio); c->dial_aio = NULL; - nni_aio_set_prov_extra(aio, 0, NULL); + nni_aio_set_prov_data(aio, NULL); nni_mtx_unlock(&d->mtx); nni_aio_finish_error(aio, rv); @@ -148,7 +148,7 @@ tcp_dialer_cb(nni_posix_pfd *pfd, unsigned ev, void *arg) c->dial_aio = NULL; nni_aio_list_remove(aio); - nni_aio_set_prov_extra(aio, 0, NULL); + nni_aio_set_prov_data(aio, NULL); nd = d->nodelay ? 1 : 0; ka = d->keepalive ? 1 : 0; @@ -237,14 +237,14 @@ nni_tcp_dial(nni_tcp_dialer *d, const nni_sockaddr *sa, nni_aio *aio) goto error; } c->dial_aio = aio; - nni_aio_set_prov_extra(aio, 0, c); + nni_aio_set_prov_data(aio, c); nni_list_append(&d->connq, aio); nni_mtx_unlock(&d->mtx); return; } // Immediate connect, cool! This probably only happens - // on loopback, and probably not on every platform. - nni_aio_set_prov_extra(aio, 0, NULL); + // on loop back, and probably not on every platform. + nni_aio_set_prov_data(aio, NULL); nd = d->nodelay ? 1 : 0; ka = d->keepalive ? 1 : 0; nni_mtx_unlock(&d->mtx); @@ -254,7 +254,7 @@ nni_tcp_dial(nni_tcp_dialer *d, const nni_sockaddr *sa, nni_aio *aio) return; error: - nni_aio_set_prov_extra(aio, 0, NULL); + nni_aio_set_prov_data(aio, NULL); nni_mtx_unlock(&d->mtx); nng_stream_free(&c->stream); nni_aio_finish_error(aio, rv); diff --git a/src/platform/windows/win_resolv.c b/src/platform/windows/win_resolv.c index f855e255..528da451 100644 --- a/src/platform/windows/win_resolv.c +++ b/src/platform/windows/win_resolv.c @@ -56,11 +56,11 @@ resolv_cancel(nni_aio *aio, void *arg, int rv) resolv_item *item = arg; nni_mtx_lock(&resolv_mtx); - if (item != nni_aio_get_prov_extra(aio, 0)) { + if (item != nni_aio_get_prov_data(aio)) { nni_mtx_unlock(&resolv_mtx); return; } - nni_aio_set_prov_extra(aio, 0, NULL); + nni_aio_set_prov_data(aio, NULL); if (nni_aio_list_active(aio)) { // We have not been picked up by a resolver thread yet, // so we can just discard everything. @@ -248,7 +248,7 @@ nni_resolv_ip(const char *host, const char *serv, int family, bool passive, if (resolv_fini) { rv = NNG_ECLOSED; } else { - nni_aio_set_prov_extra(aio, 0, item); + nni_aio_set_prov_data(aio, item); rv = nni_aio_schedule(aio, resolv_cancel, item); } if (rv != 0) { @@ -282,7 +282,7 @@ resolv_worker(void *notused) continue; } - item = nni_aio_get_prov_extra(aio, 0); + item = nni_aio_get_prov_data(aio); nni_aio_list_remove(aio); // Now attempt to do the work. This runs synchronously. @@ -292,7 +292,7 @@ resolv_worker(void *notused) // Check to make sure we were not canceled. if ((aio = item->aio) != NULL) { - nni_aio_set_prov_extra(aio, 0, NULL); + nni_aio_set_prov_data(aio, NULL); item->aio = NULL; item->sa = NULL; diff --git a/src/platform/windows/win_tcpdial.c b/src/platform/windows/win_tcpdial.c index 3353d380..9463c241 100644 --- a/src/platform/windows/win_tcpdial.c +++ b/src/platform/windows/win_tcpdial.c @@ -79,7 +79,7 @@ nni_tcp_dialer_close(nni_tcp_dialer *d) NNI_LIST_FOREACH (&d->aios, aio) { nni_tcp_conn *c; - if ((c = nni_aio_get_prov_extra(aio, 0)) != NULL) { + if ((c = nni_aio_get_prov_data(aio)) != NULL) { c->conn_rv = NNG_ECLOSED; CancelIoEx((HANDLE) c->s, &c->conn_io.olpd); } @@ -116,7 +116,7 @@ tcp_dial_cancel(nni_aio *aio, void *arg, int rv) nni_tcp_conn * c; nni_mtx_lock(&d->mtx); - if ((c = nni_aio_get_prov_extra(aio, 0)) != NULL) { + if ((c = nni_aio_get_prov_data(aio)) != NULL) { if (c->conn_rv == 0) { c->conn_rv = rv; } @@ -144,7 +144,7 @@ tcp_dial_cb(nni_win_io *io, int rv, size_t cnt) } c->conn_aio = NULL; - nni_aio_set_prov_extra(aio, 0, NULL); + nni_aio_set_prov_data(aio, NULL); nni_aio_list_remove(aio); if (c->conn_rv != 0) { rv = c->conn_rv; @@ -240,7 +240,7 @@ nni_tcp_dial(nni_tcp_dialer *d, const nni_sockaddr *sa, nni_aio *aio) } c->dialer = d; - nni_aio_set_prov_extra(aio, 0, c); + nni_aio_set_prov_data(aio, c); if ((rv = nni_aio_schedule(aio, tcp_dial_cancel, d)) != 0) { nni_mtx_unlock(&d->mtx); nng_stream_free(&c->ops); diff --git a/src/platform/windows/win_tcplisten.c b/src/platform/windows/win_tcplisten.c index 1e87fd31..ee829dba 100644 --- a/src/platform/windows/win_tcplisten.c +++ b/src/platform/windows/win_tcplisten.c @@ -1,5 +1,5 @@ // -// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // Copyright 2018 Devolutions <info@devolutions.net> // @@ -102,7 +102,7 @@ tcp_accept_cb(nni_win_io *io, int rv, size_t cnt) return; } c->conn_aio = NULL; - nni_aio_set_prov_extra(aio, 0, NULL); + nni_aio_set_prov_data(aio, NULL); nni_aio_list_remove(aio); if (c->conn_rv != 0) { rv = c->conn_rv; @@ -174,7 +174,7 @@ nni_tcp_listener_close(nni_tcp_listener *l) NNI_LIST_FOREACH (&l->aios, aio) { nni_tcp_conn *c; - if ((c = nni_aio_get_prov_extra(aio, 0)) != NULL) { + if ((c = nni_aio_get_prov_data(aio)) != NULL) { c->conn_rv = NNG_ECLOSED; CancelIoEx((HANDLE) c->s, &c->conn_io.olpd); } @@ -275,7 +275,7 @@ tcp_accept_cancel(nni_aio *aio, void *arg, int rv) nni_tcp_conn * c; nni_mtx_lock(&l->mtx); - if ((c = nni_aio_get_prov_extra(aio, 0)) != NULL) { + if ((c = nni_aio_get_prov_data(aio)) != NULL) { if (c->conn_rv == 0) { c->conn_rv = rv; } @@ -323,10 +323,10 @@ nni_tcp_listener_accept(nni_tcp_listener *l, nni_aio *aio) } c->listener = l; c->conn_aio = aio; - nni_aio_set_prov_extra(aio, 0, c); + nni_aio_set_prov_data(aio, c); if (((rv = nni_win_io_init(&c->conn_io, tcp_accept_cb, c)) != 0) || ((rv = nni_aio_schedule(aio, tcp_accept_cancel, l)) != 0)) { - nni_aio_set_prov_extra(aio, 0, NULL); + nni_aio_set_prov_data(aio, NULL); nni_mtx_unlock(&l->mtx); nng_stream_free(&c->ops); nni_aio_finish_error(aio, rv); diff --git a/src/supplemental/http/http_conn.c b/src/supplemental/http/http_conn.c index 646a3067..03d1a1f5 100644 --- a/src/supplemental/http/http_conn.c +++ b/src/supplemental/http/http_conn.c @@ -1,5 +1,5 @@ // -// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // Copyright 2019 Devolutions <info@devolutions.net> // @@ -40,16 +40,9 @@ enum write_flavor { HTTP_WR_RES, }; -#define SET_RD_FLAVOR(aio, f) \ - nni_aio_set_prov_extra(aio, 0, ((void *) (intptr_t)(f))) -#define GET_RD_FLAVOR(aio) (int) ((intptr_t) nni_aio_get_prov_extra(aio, 0)) -#define SET_WR_FLAVOR(aio, f) \ - nni_aio_set_prov_extra(aio, 0, ((void *) (intptr_t)(f))) -#define GET_WR_FLAVOR(aio) (int) ((intptr_t) nni_aio_get_prov_extra(aio, 0)) - struct nng_http_conn { nng_stream *sock; - void * ctx; + void *ctx; bool closed; nni_list rdq; // high level http read requests nni_list wrq; // high level http write requests @@ -61,11 +54,14 @@ struct nng_http_conn { nni_mtx mtx; - uint8_t *rd_buf; - size_t rd_get; - size_t rd_put; - size_t rd_bufsz; - bool rd_buffered; + enum read_flavor rd_flavor; + uint8_t *rd_buf; + size_t rd_get; + size_t rd_put; + size_t rd_bufsz; + bool rd_buffered; + + enum write_flavor wr_flavor; }; void @@ -140,7 +136,7 @@ http_rd_buf(nni_http_conn *conn, nni_aio *aio) rbuf += conn->rd_get; - switch (GET_RD_FLAVOR(aio)) { + switch (conn->rd_flavor) { case HTTP_RD_RAW: raw = true; // FALLTHROUGH case HTTP_RD_FULL: @@ -185,7 +181,7 @@ http_rd_buf(nni_http_conn *conn, nni_aio *aio) case HTTP_RD_REQ: rv = nni_http_req_parse( - nni_aio_get_prov_extra(aio, 1), rbuf, cnt, &n); + nni_aio_get_prov_data(aio), rbuf, cnt, &n); conn->rd_get += n; if (conn->rd_get == conn->rd_put) { conn->rd_get = conn->rd_put = 0; @@ -202,7 +198,7 @@ http_rd_buf(nni_http_conn *conn, nni_aio *aio) case HTTP_RD_RES: rv = nni_http_res_parse( - nni_aio_get_prov_extra(aio, 1), rbuf, cnt, &n); + nni_aio_get_prov_data(aio), rbuf, cnt, &n); conn->rd_get += n; if (conn->rd_get == conn->rd_put) { conn->rd_get = conn->rd_put = 0; @@ -219,7 +215,7 @@ http_rd_buf(nni_http_conn *conn, nni_aio *aio) case HTTP_RD_CHUNK: rv = nni_http_chunks_parse( - nni_aio_get_prov_extra(aio, 1), rbuf, cnt, &n); + nni_aio_get_prov_data(aio), rbuf, cnt, &n); conn->rd_get += n; if (conn->rd_get == conn->rd_put) { conn->rd_get = conn->rd_put = 0; @@ -278,12 +274,12 @@ static void http_rd_cb(void *arg) { nni_http_conn *conn = arg; - nni_aio * aio = conn->rd_aio; - nni_aio * uaio; + nni_aio *aio = conn->rd_aio; + nni_aio *uaio; size_t cnt; int rv; unsigned niov; - nni_iov * iov; + nni_iov *iov; nni_mtx_lock(&conn->mtx); @@ -365,7 +361,7 @@ http_rd_cancel(nni_aio *aio, void *arg, int rv) } static void -http_rd_submit(nni_http_conn *conn, nni_aio *aio) +http_rd_submit(nni_http_conn *conn, nni_aio *aio, enum read_flavor flavor) { int rv; @@ -380,6 +376,7 @@ http_rd_submit(nni_http_conn *conn, nni_aio *aio) nni_aio_finish_error(aio, rv); return; } + conn->rd_flavor = flavor; nni_list_append(&conn->rdq, aio); if (conn->rd_uaio == NULL) { http_rd_start(conn); @@ -411,8 +408,8 @@ static void http_wr_cb(void *arg) { nni_http_conn *conn = arg; - nni_aio * aio = conn->wr_aio; - nni_aio * uaio; + nni_aio *aio = conn->wr_aio; + nni_aio *uaio; int rv; size_t n; @@ -442,7 +439,7 @@ http_wr_cb(void *arg) n = nni_aio_count(aio); nni_aio_bump_count(uaio, n); - if (GET_WR_FLAVOR(uaio) == HTTP_WR_RAW) { + if (conn->wr_flavor == HTTP_WR_RAW) { // For raw data, we just send partial completion // notices to the consumer. goto done; @@ -484,7 +481,7 @@ http_wr_cancel(nni_aio *aio, void *arg, int rv) } static void -http_wr_submit(nni_http_conn *conn, nni_aio *aio) +http_wr_submit(nni_http_conn *conn, nni_aio *aio, enum write_flavor flavor) { int rv; @@ -499,6 +496,7 @@ http_wr_submit(nni_http_conn *conn, nni_aio *aio) nni_aio_finish_error(aio, rv); return; } + conn->wr_flavor = flavor; nni_list_append(&conn->wrq, aio); if (conn->wr_uaio == NULL) { @@ -509,55 +507,50 @@ http_wr_submit(nni_http_conn *conn, nni_aio *aio) void nni_http_read_req(nni_http_conn *conn, nni_http_req *req, nni_aio *aio) { - SET_RD_FLAVOR(aio, HTTP_RD_REQ); - nni_aio_set_prov_extra(aio, 1, req); + nni_aio_set_prov_data(aio, req); nni_mtx_lock(&conn->mtx); - http_rd_submit(conn, aio); + http_rd_submit(conn, aio, HTTP_RD_REQ); nni_mtx_unlock(&conn->mtx); } void nni_http_read_res(nni_http_conn *conn, nni_http_res *res, nni_aio *aio) { - SET_RD_FLAVOR(aio, HTTP_RD_RES); - nni_aio_set_prov_extra(aio, 1, res); + nni_aio_set_prov_data(aio, res); nni_mtx_lock(&conn->mtx); - http_rd_submit(conn, aio); + http_rd_submit(conn, aio, HTTP_RD_RES); nni_mtx_unlock(&conn->mtx); } void nni_http_read_chunks(nni_http_conn *conn, nni_http_chunks *cl, nni_aio *aio) { - SET_RD_FLAVOR(aio, HTTP_RD_CHUNK); - nni_aio_set_prov_extra(aio, 1, cl); + nni_aio_set_prov_data(aio, cl); nni_mtx_lock(&conn->mtx); - http_rd_submit(conn, aio); + http_rd_submit(conn, aio, HTTP_RD_CHUNK); nni_mtx_unlock(&conn->mtx); } void nni_http_read_full(nni_http_conn *conn, nni_aio *aio) { - SET_RD_FLAVOR(aio, HTTP_RD_FULL); - nni_aio_set_prov_extra(aio, 1, NULL); + nni_aio_set_prov_data(aio, NULL); nni_mtx_lock(&conn->mtx); - http_rd_submit(conn, aio); + http_rd_submit(conn, aio, HTTP_RD_FULL); nni_mtx_unlock(&conn->mtx); } void nni_http_read(nni_http_conn *conn, nni_aio *aio) { - SET_RD_FLAVOR(aio, HTTP_RD_RAW); - nni_aio_set_prov_extra(aio, 1, NULL); + nni_aio_set_prov_data(aio, NULL); nni_mtx_lock(&conn->mtx); - http_rd_submit(conn, aio); + http_rd_submit(conn, aio, HTTP_RD_RAW); nni_mtx_unlock(&conn->mtx); } @@ -565,9 +558,9 @@ void nni_http_write_req(nni_http_conn *conn, nni_http_req *req, nni_aio *aio) { int rv; - void * buf; + void *buf; size_t bufsz; - void * data; + void *data; size_t size; nni_iov iov[2]; int niov; @@ -587,10 +580,8 @@ nni_http_write_req(nni_http_conn *conn, nni_http_req *req, nni_aio *aio) } nni_aio_set_iov(aio, niov, iov); - SET_WR_FLAVOR(aio, HTTP_WR_REQ); - nni_mtx_lock(&conn->mtx); - http_wr_submit(conn, aio); + http_wr_submit(conn, aio, HTTP_WR_REQ); nni_mtx_unlock(&conn->mtx); } @@ -598,9 +589,9 @@ void nni_http_write_res(nni_http_conn *conn, nni_http_res *res, nni_aio *aio) { int rv; - void * buf; + void *buf; size_t bufsz; - void * data; + void *data; size_t size; nni_iov iov[2]; int nio; @@ -620,30 +611,24 @@ nni_http_write_res(nni_http_conn *conn, nni_http_res *res, nni_aio *aio) } nni_aio_set_iov(aio, nio, iov); - SET_WR_FLAVOR(aio, HTTP_WR_RES); - nni_mtx_lock(&conn->mtx); - http_wr_submit(conn, aio); + http_wr_submit(conn, aio, HTTP_WR_RES); nni_mtx_unlock(&conn->mtx); } void nni_http_write(nni_http_conn *conn, nni_aio *aio) { - SET_WR_FLAVOR(aio, HTTP_WR_RAW); - nni_mtx_lock(&conn->mtx); - http_wr_submit(conn, aio); + http_wr_submit(conn, aio, HTTP_WR_RAW); nni_mtx_unlock(&conn->mtx); } void nni_http_write_full(nni_http_conn *conn, nni_aio *aio) { - SET_WR_FLAVOR(aio, HTTP_WR_FULL); - nni_mtx_lock(&conn->mtx); - http_wr_submit(conn, aio); + http_wr_submit(conn, aio, HTTP_WR_FULL); nni_mtx_unlock(&conn->mtx); } diff --git a/src/supplemental/websocket/websocket.c b/src/supplemental/websocket/websocket.c index 416d968c..d1c9c8d5 100644 --- a/src/supplemental/websocket/websocket.c +++ b/src/supplemental/websocket/websocket.c @@ -714,7 +714,7 @@ ws_write_cancel(nni_aio *aio, void *arg, int rv) nni_mtx_unlock(&ws->mtx); return; } - frame = nni_aio_get_prov_extra(aio, 0); + frame = nni_aio_get_prov_data(aio); if (frame == ws->txframe) { nni_aio_abort(ws->txaio, rv); // We will wait for callback on the txaio to finish aio. @@ -2739,7 +2739,7 @@ ws_str_send(void *arg, nni_aio *aio) ws_frame_fini(frame); return; } - nni_aio_set_prov_extra(aio, 0, frame); + nni_aio_set_prov_data(aio, frame); nni_list_append(&ws->sendq, aio); nni_list_append(&ws->txq, frame); ws_start_write(ws); |
