From 6e5f6a26beec0a44d25625cacb5095cdc7a94146 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Mon, 20 Aug 2018 09:00:46 -0700 Subject: fixes #664 aio cancellation could be better This changes the signature of the aio cancellation routines to take the argument for cancellation directly, so we do not need to lookup the argument using the nni_aio_get_prov_data. We should probably consider eliminating nni_aio_get_prov_data, and co, and changing the prov_extra to reflect prov_data. Later. --- src/supplemental/http/http_client.c | 4 ++-- src/supplemental/http/http_conn.c | 8 ++++---- src/supplemental/tls/mbedtls/tls.c | 4 ++-- src/supplemental/websocket/websocket.c | 24 +++++++++++------------- 4 files changed, 19 insertions(+), 21 deletions(-) (limited to 'src/supplemental') diff --git a/src/supplemental/http/http_client.c b/src/supplemental/http/http_client.c index da4ae5c8..1639b3ec 100644 --- a/src/supplemental/http/http_client.c +++ b/src/supplemental/http/http_client.c @@ -232,9 +232,9 @@ nni_http_client_get_tls(nni_http_client *c, struct nng_tls_config **tlsp) } static void -http_dial_cancel(nni_aio *aio, int rv) +http_dial_cancel(nni_aio *aio, void *arg, int rv) { - nni_http_client *c = nni_aio_get_prov_data(aio); + nni_http_client *c = arg; nni_mtx_lock(&c->mtx); if (nni_aio_list_active(aio)) { nni_aio_list_remove(aio); diff --git a/src/supplemental/http/http_conn.c b/src/supplemental/http/http_conn.c index 169918e9..b17b02cf 100644 --- a/src/supplemental/http/http_conn.c +++ b/src/supplemental/http/http_conn.c @@ -350,9 +350,9 @@ http_rd_cb(void *arg) } static void -http_rd_cancel(nni_aio *aio, int rv) +http_rd_cancel(nni_aio *aio, void *arg, int rv) { - nni_http_conn *conn = nni_aio_get_prov_data(aio); + nni_http_conn *conn = arg; nni_mtx_lock(&conn->mtx); if (aio == conn->rd_uaio) { @@ -469,9 +469,9 @@ done: } static void -http_wr_cancel(nni_aio *aio, int rv) +http_wr_cancel(nni_aio *aio, void *arg, int rv) { - nni_http_conn *conn = nni_aio_get_prov_data(aio); + nni_http_conn *conn = arg; nni_mtx_lock(&conn->mtx); if (aio == conn->wr_uaio) { diff --git a/src/supplemental/tls/mbedtls/tls.c b/src/supplemental/tls/mbedtls/tls.c index 42333783..0d15ae9f 100644 --- a/src/supplemental/tls/mbedtls/tls.c +++ b/src/supplemental/tls/mbedtls/tls.c @@ -371,9 +371,9 @@ nni_tls_init(nni_tls **tpp, nng_tls_config *cfg, nni_tcp_conn *tcp) } static void -nni_tls_cancel(nni_aio *aio, int rv) +nni_tls_cancel(nni_aio *aio, void *arg, int rv) { - nni_tls *tp = nni_aio_get_prov_data(aio); + nni_tls *tp = arg; nni_mtx_lock(&tp->lk); if (nni_aio_list_active(aio)) { nni_aio_list_remove(aio); diff --git a/src/supplemental/websocket/websocket.c b/src/supplemental/websocket/websocket.c index efa0fdf8..a1553704 100644 --- a/src/supplemental/websocket/websocket.c +++ b/src/supplemental/websocket/websocket.c @@ -517,9 +517,9 @@ ws_start_write(nni_ws *ws) } static void -ws_cancel_close(nni_aio *aio, int rv) +ws_cancel_close(nni_aio *aio, void *arg, int rv) { - nni_ws *ws = nni_aio_get_prov_data(aio); + nni_ws *ws = arg; nni_mtx_lock(&ws->mtx); if (ws->wclose) { ws->wclose = false; @@ -616,15 +616,13 @@ ws_write_cb(void *arg) } static void -ws_write_cancel(nni_aio *aio, int rv) +ws_write_cancel(nni_aio *aio, void *arg, int rv) { - nni_ws * ws; + nni_ws * ws = arg; ws_msg * wm; ws_frame *frame; - // Is this aio active? We can tell by looking at the - // active tx frame. - ws = nni_aio_get_prov_data(aio); + // Is this aio active? We can tell by looking at the active tx frame. nni_mtx_lock(&ws->mtx); if (!nni_aio_list_active(aio)) { @@ -1038,9 +1036,9 @@ ws_read_cb(void *arg) } static void -ws_read_cancel(nni_aio *aio, int rv) +ws_read_cancel(nni_aio *aio, void *arg, int rv) { - nni_ws *ws = nni_aio_get_prov_data(aio); + nni_ws *ws = arg; ws_msg *wm; nni_mtx_lock(&ws->mtx); @@ -1676,9 +1674,9 @@ nni_ws_listener_proto(nni_ws_listener *l, const char *proto) } static void -ws_accept_cancel(nni_aio *aio, int rv) +ws_accept_cancel(nni_aio *aio, void *arg, int rv) { - nni_ws_listener *l = nni_aio_get_prov_data(aio); + nni_ws_listener *l = arg; nni_mtx_lock(&l->mtx); if (nni_aio_list_active(aio)) { @@ -2031,9 +2029,9 @@ nni_ws_dialer_proto(nni_ws_dialer *d, const char *proto) } static void -ws_dial_cancel(nni_aio *aio, int rv) +ws_dial_cancel(nni_aio *aio, void *arg, int rv) { - nni_ws *ws = nni_aio_get_prov_data(aio); + nni_ws *ws = arg; nni_mtx_lock(&ws->mtx); if (aio == ws->useraio) { -- cgit v1.2.3-70-g09d2