aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-12-26 16:02:46 -0800
committerGarrett D'Amore <garrett@damore.org>2024-12-26 17:45:44 -0800
commit813a71e1e41ff6a8bc9d9582604aebdb75767c0c (patch)
tree49b1be6570bd354fbc7a2df66161555d7eebd26e
parent218a24e194562449aeffc5a113bb9582b2a87952 (diff)
downloadnng-813a71e1e41ff6a8bc9d9582604aebdb75767c0c.tar.gz
nng-813a71e1e41ff6a8bc9d9582604aebdb75767c0c.tar.bz2
nng-813a71e1e41ff6a8bc9d9582604aebdb75767c0c.zip
http: more nni_aio_start changes
-rw-r--r--src/supplemental/http/http_client.c22
-rw-r--r--src/supplemental/http/http_public.c40
2 files changed, 16 insertions, 46 deletions
diff --git a/src/supplemental/http/http_client.c b/src/supplemental/http/http_client.c
index 03125abf..e2a8be3a 100644
--- a/src/supplemental/http/http_client.c
+++ b/src/supplemental/http/http_client.c
@@ -182,14 +182,10 @@ http_dial_cancel(nni_aio *aio, void *arg, int rv)
void
nni_http_client_connect(nni_http_client *c, nni_aio *aio)
{
- int rv;
- if (nni_aio_begin(aio) != 0) {
- return;
- }
+ nni_aio_reset(aio);
nni_mtx_lock(&c->mtx);
- if ((rv = nni_aio_schedule(aio, http_dial_cancel, c)) != 0) {
+ if (!nni_aio_start(aio, http_dial_cancel, c)) {
nni_mtx_unlock(&c->mtx);
- nni_aio_finish_error(aio, rv);
return;
}
nni_list_append(&c->aios, aio);
@@ -377,9 +373,7 @@ nni_http_transact_conn(
http_txn *txn;
int rv;
- if (nni_aio_begin(aio) != 0) {
- return;
- }
+ nni_aio_reset(aio);
if ((txn = NNI_ALLOC_STRUCT(txn)) == NULL) {
nni_aio_finish_error(aio, NNG_ENOMEM);
return;
@@ -397,9 +391,8 @@ nni_http_transact_conn(
txn->state = HTTP_SENDING;
nni_mtx_lock(&http_txn_lk);
- if ((rv = nni_aio_schedule(aio, http_txn_cancel, txn)) != 0) {
+ if (!nni_aio_start(aio, http_txn_cancel, txn)) {
nni_mtx_unlock(&http_txn_lk);
- nni_aio_finish_error(aio, rv);
http_txn_fini(txn);
return;
}
@@ -420,9 +413,7 @@ nni_http_transact(nni_http_client *client, nni_http_req *req,
http_txn *txn;
int rv;
- if (nni_aio_begin(aio) != 0) {
- return;
- }
+ nni_aio_reset(aio);
if ((txn = NNI_ALLOC_STRUCT(txn)) == NULL) {
nni_aio_finish_error(aio, NNG_ENOMEM);
return;
@@ -447,9 +438,8 @@ nni_http_transact(nni_http_client *client, nni_http_req *req,
txn->state = HTTP_CONNECTING;
nni_mtx_lock(&http_txn_lk);
- if ((rv = nni_aio_schedule(aio, http_txn_cancel, txn)) != 0) {
+ if (!nni_aio_start(aio, http_txn_cancel, txn)) {
nni_mtx_unlock(&http_txn_lk);
- nni_aio_finish_error(aio, rv);
http_txn_fini(txn);
return;
}
diff --git a/src/supplemental/http/http_public.c b/src/supplemental/http/http_public.c
index 49638b66..32f1e275 100644
--- a/src/supplemental/http/http_public.c
+++ b/src/supplemental/http/http_public.c
@@ -401,9 +401,7 @@ nng_http_conn_read(nng_http_conn *conn, nng_aio *aio)
nni_http_read(conn, aio);
#else
NNI_ARG_UNUSED(conn);
- if (nni_aio_begin(aio) == 0) {
- nni_aio_finish_error(aio, NNG_ENOTSUP);
- }
+ nni_aio_finish_error(aio, NNG_ENOTSUP);
#endif
}
@@ -414,9 +412,7 @@ nng_http_conn_read_all(nng_http_conn *conn, nng_aio *aio)
nni_http_read_full(conn, aio);
#else
NNI_ARG_UNUSED(conn);
- if (nni_aio_begin(aio) == 0) {
- nni_aio_finish_error(aio, NNG_ENOTSUP);
- }
+ nni_aio_finish_error(aio, NNG_ENOTSUP);
#endif
}
@@ -427,9 +423,7 @@ nng_http_conn_write(nng_http_conn *conn, nng_aio *aio)
nni_http_write(conn, aio);
#else
NNI_ARG_UNUSED(conn);
- if (nni_aio_begin(aio) == 0) {
- nni_aio_finish_error(aio, NNG_ENOTSUP);
- }
+ nni_aio_finish_error(aio, NNG_ENOTSUP);
#endif
}
@@ -452,9 +446,7 @@ nng_http_conn_write_req(nng_http_conn *conn, nng_http_req *req, nng_aio *aio)
#else
NNI_ARG_UNUSED(conn);
NNI_ARG_UNUSED(req);
- if (nni_aio_begin(aio) == 0) {
- nni_aio_finish_error(aio, NNG_ENOTSUP);
- }
+ nni_aio_finish_error(aio, NNG_ENOTSUP);
#endif
}
@@ -466,9 +458,7 @@ nng_http_conn_write_res(nng_http_conn *conn, nng_http_res *res, nng_aio *aio)
#else
NNI_ARG_UNUSED(conn);
NNI_ARG_UNUSED(res);
- if (nni_aio_begin(aio) == 0) {
- nni_aio_finish_error(aio, NNG_ENOTSUP);
- }
+ nni_aio_finish_error(aio, NNG_ENOTSUP);
#endif
}
@@ -480,9 +470,7 @@ nng_http_conn_read_req(nng_http_conn *conn, nng_http_req *req, nng_aio *aio)
#else
NNI_ARG_UNUSED(conn);
NNI_ARG_UNUSED(req);
- if (nni_aio_begin(aio) == 0) {
- nni_aio_finish_error(aio, NNG_ENOTSUP);
- }
+ nni_aio_finish_error(aio, NNG_ENOTSUP);
#endif
}
@@ -494,9 +482,7 @@ nng_http_conn_read_res(nng_http_conn *conn, nng_http_res *res, nng_aio *aio)
#else
NNI_ARG_UNUSED(conn);
NNI_ARG_UNUSED(res);
- if (nni_aio_begin(aio) == 0) {
- nni_aio_finish_error(aio, NNG_ENOTSUP);
- }
+ nni_aio_finish_error(aio, NNG_ENOTSUP);
#endif
}
@@ -871,9 +857,7 @@ nng_http_client_connect(nng_http_client *cli, nng_aio *aio)
nni_http_client_connect(cli, aio);
#else
NNI_ARG_UNUSED(cli);
- if (nni_aio_begin(aio) == 0) {
- nni_aio_finish_error(aio, NNG_ENOTSUP);
- }
+ nni_aio_finish_error(aio, NNG_ENOTSUP);
#endif
}
@@ -887,9 +871,7 @@ nng_http_client_transact(
NNI_ARG_UNUSED(cli);
NNI_ARG_UNUSED(req);
NNI_ARG_UNUSED(res);
- if (nni_aio_begin(aio) == 0) {
- nni_aio_finish_error(aio, NNG_ENOTSUP);
- }
+ nni_aio_finish_error(aio, NNG_ENOTSUP);
#endif
}
@@ -903,9 +885,7 @@ nng_http_conn_transact(
NNI_ARG_UNUSED(conn);
NNI_ARG_UNUSED(req);
NNI_ARG_UNUSED(res);
- if (nni_aio_begin(aio) == 0) {
- nni_aio_finish_error(aio, NNG_ENOTSUP);
- }
+ nni_aio_finish_error(aio, NNG_ENOTSUP);
#endif
}