aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/aio.c45
-rw-r--r--src/core/aio.h3
-rw-r--r--src/core/endpt.c9
-rw-r--r--src/core/url.c4
4 files changed, 17 insertions, 44 deletions
diff --git a/src/core/aio.c b/src/core/aio.c
index ee1ddf2a..1c293020 100644
--- a/src/core/aio.c
+++ b/src/core/aio.c
@@ -74,17 +74,14 @@ struct nng_aio {
// Read/write operations.
nni_iov *a_iov;
- int a_niov;
+ unsigned a_niov;
nni_iov a_iovinl[4]; // inline IOVs - when the IOV list is short
nni_iov *a_iovalloc; // dynamically allocated IOVs
- int a_niovalloc; // number of allocated IOVs
+ unsigned a_niovalloc; // number of allocated IOVs
// Message operations.
nni_msg *a_msg;
- // Connect/accept operations.
- void *a_pipe; // opaque pipe handle
-
// User scratch data. Consumers may store values here, which
// must be preserved by providers and the framework.
void *a_user_data[4];
@@ -218,18 +215,6 @@ nni_aio_get_msg(nni_aio *aio)
}
void
-nni_aio_set_pipe(nni_aio *aio, void *p)
-{
- aio->a_pipe = p;
-}
-
-void *
-nni_aio_get_pipe(nni_aio *aio)
-{
- return (aio->a_pipe);
-}
-
-void
nni_aio_set_data(nni_aio *aio, int index, void *data)
{
if ((index >= 0) && (index < NNI_NUM_ELEMENTS(aio->a_user_data))) {
@@ -330,6 +315,9 @@ nni_aio_start(nni_aio *aio, nni_aio_cancelfn cancelfn, void *data)
aio->a_prov_cancel = cancelfn;
aio->a_prov_data = data;
aio->a_active = 1;
+ for (int i = 0; i < NNI_NUM_ELEMENTS(aio->a_outputs); i++) {
+ aio->a_outputs[i] = NULL;
+ }
// Convert the relative timeout to an absolute timeout.
switch (aio->a_timeout) {
@@ -370,8 +358,7 @@ nni_aio_abort(nni_aio *aio, int rv)
// I/O provider related functions.
static void
-nni_aio_finish_impl(
- nni_aio *aio, int result, size_t count, void *pipe, nni_msg *msg)
+nni_aio_finish_impl(nni_aio *aio, int rv, size_t count, nni_msg *msg)
{
nni_mtx_lock(&nni_aio_lk);
@@ -380,12 +367,9 @@ nni_aio_finish_impl(
nni_list_node_remove(&aio->a_expire_node);
aio->a_pend = 1;
- aio->a_result = result;
+ aio->a_result = rv;
aio->a_count = count;
aio->a_prov_cancel = NULL;
- if (pipe) {
- aio->a_pipe = pipe;
- }
if (msg) {
aio->a_msg = msg;
}
@@ -409,27 +393,20 @@ nni_aio_finish_impl(
void
nni_aio_finish(nni_aio *aio, int result, size_t count)
{
- nni_aio_finish_impl(aio, result, count, NULL, NULL);
+ nni_aio_finish_impl(aio, result, count, NULL);
}
void
nni_aio_finish_error(nni_aio *aio, int result)
{
- nni_aio_finish_impl(aio, result, 0, NULL, NULL);
-}
-
-void
-nni_aio_finish_pipe(nni_aio *aio, void *pipe)
-{
- NNI_ASSERT(pipe != NULL);
- nni_aio_finish_impl(aio, 0, 0, pipe, NULL);
+ nni_aio_finish_impl(aio, result, 0, NULL);
}
void
nni_aio_finish_msg(nni_aio *aio, nni_msg *msg)
{
NNI_ASSERT(msg != NULL);
- nni_aio_finish_impl(aio, 0, nni_msg_len(msg), NULL, msg);
+ nni_aio_finish_impl(aio, 0, nni_msg_len(msg), msg);
}
void
@@ -609,7 +586,7 @@ nni_aio_iov_count(nni_aio *aio)
{
size_t resid = 0;
- for (int i = 0; i < aio->a_niov; i++) {
+ for (unsigned i = 0; i < aio->a_niov; i++) {
resid += aio->a_iov[i].iov_len;
}
return (resid);
diff --git a/src/core/aio.h b/src/core/aio.h
index b17c8e97..718eeb91 100644
--- a/src/core/aio.h
+++ b/src/core/aio.h
@@ -78,8 +78,6 @@ extern void *nni_aio_get_output(nni_aio *, int);
// XXX: These should be refactored in terms of generic inputs and outputs.
extern void nni_aio_set_msg(nni_aio *, nni_msg *);
extern nni_msg *nni_aio_get_msg(nni_aio *);
-extern void nni_aio_set_pipe(nni_aio *, void *);
-extern void * nni_aio_get_pipe(nni_aio *);
// nni_aio_set_synch sets a synchronous completion flag on the AIO.
// When this is set, the next time the AIO is completed, the callback
@@ -126,7 +124,6 @@ extern int nni_aio_list_active(nni_aio *);
// nni_aio_finish is called by the provider when an operation is complete.
extern void nni_aio_finish(nni_aio *, int, size_t);
extern void nni_aio_finish_error(nni_aio *, int);
-extern void nni_aio_finish_pipe(nni_aio *, void *);
extern void nni_aio_finish_msg(nni_aio *, nni_msg *);
// nni_aio_abort is used to abort an operation. Any pending I/O or
diff --git a/src/core/endpt.c b/src/core/endpt.c
index 4a2c3097..b7167ad7 100644
--- a/src/core/endpt.c
+++ b/src/core/endpt.c
@@ -364,7 +364,7 @@ nni_ep_con_cb(void *arg)
int rv;
if ((rv = nni_aio_result(aio)) == 0) {
- rv = nni_pipe_create(ep, nni_aio_get_pipe(aio));
+ rv = nni_pipe_create(ep, nni_aio_get_output(aio, 0));
}
nni_mtx_lock(&ep->ep_mtx);
switch (rv) {
@@ -448,7 +448,7 @@ nni_ep_dial(nni_ep *ep, int flags)
// As we're synchronous, we also have to handle the completion.
if (((rv = nni_aio_result(aio)) != 0) ||
- ((rv = nni_pipe_create(ep, nni_aio_get_pipe(aio))) != 0)) {
+ ((rv = nni_pipe_create(ep, nni_aio_get_output(aio, 0))) != 0)) {
nni_mtx_lock(&ep->ep_mtx);
ep->ep_started = 0;
nni_mtx_unlock(&ep->ep_mtx);
@@ -464,8 +464,8 @@ nni_ep_acc_cb(void *arg)
int rv;
if ((rv = nni_aio_result(aio)) == 0) {
- NNI_ASSERT(nni_aio_get_pipe(aio) != NULL);
- rv = nni_pipe_create(ep, nni_aio_get_pipe(aio));
+ NNI_ASSERT(nni_aio_get_output(aio, 0) != NULL);
+ rv = nni_pipe_create(ep, nni_aio_get_output(aio, 0));
}
nni_mtx_lock(&ep->ep_mtx);
@@ -503,7 +503,6 @@ nni_ep_acc_start(nni_ep *ep)
if (ep->ep_closing) {
return;
}
- nni_aio_set_pipe(aio, NULL);
ep->ep_ops.ep_accept(ep->ep_data, aio);
}
diff --git a/src/core/url.c b/src/core/url.c
index 6a2a4e53..2cdb43c2 100644
--- a/src/core/url.c
+++ b/src/core/url.c
@@ -284,7 +284,7 @@ nni_url_parse(nni_url **urlp, const char *raw)
rv = NNG_ENOMEM;
goto error;
}
- for (int i = 0; i < len; i++) {
+ for (size_t i = 0; i < len; i++) {
url->u_scheme[i] = tolower(s[i]);
}
url->u_scheme[len] = '\0';
@@ -334,7 +334,7 @@ nni_url_parse(nni_url **urlp, const char *raw)
}
// Copy the host portion, but make it lower case (hostnames are
// case insensitive).
- for (int i = 0; i < len; i++) {
+ for (size_t i = 0; i < len; i++) {
url->u_host[i] = tolower(s[i]);
}
url->u_host[len] = '\0';