diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-12-09 13:33:11 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-12-22 21:31:28 -0800 |
| commit | c8ce57d668d73d92a071fa86f81e07ca403d8672 (patch) | |
| tree | ad7e602e43fefa64067fdac5fcd23987a50c3a90 /src/supplemental | |
| parent | 013bb69c6be2f0a4572f4200de05e664692b6704 (diff) | |
| download | nng-c8ce57d668d73d92a071fa86f81e07ca403d8672.tar.gz nng-c8ce57d668d73d92a071fa86f81e07ca403d8672.tar.bz2 nng-c8ce57d668d73d92a071fa86f81e07ca403d8672.zip | |
aio: introduce nni_aio_defer
This will replace nni_aio_schedule, and it includes finishing the
task if needed. It does so without dropping the lock and so is
more efficient and race free.
This includes some conversion of some subsystems to it.
Diffstat (limited to 'src/supplemental')
| -rw-r--r-- | src/supplemental/http/http_conn.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/supplemental/http/http_conn.c b/src/supplemental/http/http_conn.c index 33ed70bb..9ff2c997 100644 --- a/src/supplemental/http/http_conn.c +++ b/src/supplemental/http/http_conn.c @@ -363,8 +363,6 @@ http_rd_cancel(nni_aio *aio, void *arg, int rv) static void http_rd_submit(nni_http_conn *conn, nni_aio *aio, enum read_flavor flavor) { - int rv; - if (nni_aio_begin(aio) != 0) { return; } @@ -372,8 +370,7 @@ http_rd_submit(nni_http_conn *conn, nni_aio *aio, enum read_flavor flavor) nni_aio_finish_error(aio, NNG_ECLOSED); return; } - if ((rv = nni_aio_schedule(aio, http_rd_cancel, conn)) != 0) { - nni_aio_finish_error(aio, rv); + if (!nni_aio_defer(aio, http_rd_cancel, conn)) { return; } conn->rd_flavor = flavor; @@ -483,8 +480,6 @@ http_wr_cancel(nni_aio *aio, void *arg, int rv) static void http_wr_submit(nni_http_conn *conn, nni_aio *aio, enum write_flavor flavor) { - int rv; - if (nni_aio_begin(aio) != 0) { return; } @@ -492,8 +487,7 @@ http_wr_submit(nni_http_conn *conn, nni_aio *aio, enum write_flavor flavor) nni_aio_finish_error(aio, NNG_ECLOSED); return; } - if ((rv = nni_aio_schedule(aio, http_wr_cancel, conn)) != 0) { - nni_aio_finish_error(aio, rv); + if (!nni_aio_defer(aio, http_wr_cancel, conn)) { return; } conn->wr_flavor = flavor; |
