aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/aio.c24
-rw-r--r--src/core/aio.h14
-rw-r--r--src/nng.c8
-rw-r--r--src/supplemental/http/http_public.c47
4 files changed, 46 insertions, 47 deletions
diff --git a/src/core/aio.c b/src/core/aio.c
index bbeb5cef..81020bbb 100644
--- a/src/core/aio.c
+++ b/src/core/aio.c
@@ -296,7 +296,7 @@ nni_aio_get_output(nni_aio *aio, unsigned index)
return (NULL);
}
-int
+nng_err
nni_aio_result(nni_aio *aio)
{
return (aio->a_result);
@@ -325,7 +325,7 @@ nni_aio_busy(nni_aio *aio)
void
nni_aio_reset(nni_aio *aio)
{
- aio->a_result = 0;
+ aio->a_result = NNG_OK;
aio->a_count = 0;
aio->a_abort = false;
aio->a_expire_ok = false;
@@ -362,7 +362,7 @@ nni_aio_start(nni_aio *aio, nni_aio_cancel_fn cancel, void *data)
if (!aio->a_sleep) {
aio->a_expire_ok = false;
}
- aio->a_result = 0;
+ aio->a_result = NNG_OK;
// Do this outside the lock. Note that we don't strictly need to have
// done this for the failure cases below (the task framework does the
@@ -388,14 +388,14 @@ nni_aio_start(nni_aio *aio, nni_aio_cancel_fn cancel, void *data)
aio->a_abort = false;
aio->a_expire_ok = false;
aio->a_count = 0;
- NNI_ASSERT(aio->a_result != 0);
+ NNI_ASSERT(aio->a_result != NNG_OK);
nni_mtx_unlock(&eq->eq_mtx);
nni_task_dispatch(&aio->a_task);
return (false);
}
if (timeout) {
aio->a_sleep = false;
- aio->a_result = aio->a_expire_ok ? 0 : NNG_ETIMEDOUT;
+ aio->a_result = aio->a_expire_ok ? NNG_OK : NNG_ETIMEDOUT;
aio->a_expire_ok = false;
aio->a_count = 0;
nni_mtx_unlock(&eq->eq_mtx);
@@ -419,7 +419,7 @@ nni_aio_start(nni_aio *aio, nni_aio_cancel_fn cancel, void *data)
// nni_aio_abort is called by a consumer which guarantees that the aio
// is still valid.
void
-nni_aio_abort(nni_aio *aio, int rv)
+nni_aio_abort(nni_aio *aio, nng_err rv)
{
if (aio != NULL && aio->a_init) {
nni_aio_cancel_fn fn;
@@ -451,7 +451,7 @@ nni_aio_abort(nni_aio *aio, int rv)
static void
nni_aio_finish_impl(
- nni_aio *aio, int rv, size_t count, nni_msg *msg, bool sync)
+ nni_aio *aio, nng_err rv, size_t count, nni_msg *msg, bool sync)
{
nni_aio_expire_q *eq = aio->a_expire_q;
@@ -479,21 +479,21 @@ nni_aio_finish_impl(
}
void
-nni_aio_finish(nni_aio *aio, int result, size_t count)
+nni_aio_finish(nni_aio *aio, nng_err result, size_t count)
{
nni_aio_finish_impl(aio, result, count, NULL, false);
}
void
-nni_aio_finish_sync(nni_aio *aio, int result, size_t count)
+nni_aio_finish_sync(nni_aio *aio, nng_err result, size_t count)
{
nni_aio_finish_impl(aio, result, count, NULL, true);
}
void
-nni_aio_finish_error(nni_aio *aio, int result)
+nni_aio_finish_error(nni_aio *aio, nng_err result)
{
- nni_aio_finish_impl(aio, result, 0, NULL, false);
+ nni_aio_finish_impl(aio, result, NNG_OK, NULL, false);
}
void
@@ -539,7 +539,7 @@ nni_aio_completions_init(nni_aio_completions *clp)
void
nni_aio_completions_add(
- nni_aio_completions *clp, nni_aio *aio, int result, size_t count)
+ nni_aio_completions *clp, nni_aio *aio, nng_err result, size_t count)
{
NNI_ASSERT(!nni_aio_list_active(aio));
aio->a_reap_node.rn_next = *clp;
diff --git a/src/core/aio.h b/src/core/aio.h
index cbf2c919..25475323 100644
--- a/src/core/aio.h
+++ b/src/core/aio.h
@@ -85,7 +85,7 @@ extern nni_msg *nni_aio_get_msg(nni_aio *);
// for the operation. It is only valid to call this when the operation is
// complete (such as when the callback is executed or after nni_aio_wait
// is performed).
-extern int nni_aio_result(nni_aio *);
+extern nng_err nni_aio_result(nni_aio *);
// nni_aio_count returns the number of bytes of data transferred, if any.
// As with nni_aio_result, it is only defined if the I/O operation has
@@ -114,19 +114,19 @@ extern void nni_aio_list_remove(nni_aio *);
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(nni_aio *, nng_err, size_t);
// nni_aio_finish_sync is to be called when a synchronous completion is
// desired. It is very important that the caller not hold any locks when
// calling this, but it is useful for chaining completions to minimize
// context switch overhead during completions.
-extern void nni_aio_finish_sync(nni_aio *, int, size_t);
-extern void nni_aio_finish_error(nni_aio *, int);
+extern void nni_aio_finish_sync(nni_aio *, nng_err, size_t);
+extern void nni_aio_finish_error(nni_aio *, nng_err);
extern void nni_aio_finish_msg(nni_aio *, nni_msg *);
// nni_aio_abort is used to abort an operation. Any pending I/O or
// timeouts are canceled if possible, and the callback will be returned
// with the indicated result (NNG_ECLOSED or NNG_ECANCELED is recommended.)
-extern void nni_aio_abort(nni_aio *, int rv);
+extern void nni_aio_abort(nni_aio *, nng_err);
extern void *nni_aio_get_prov_data(nni_aio *);
extern void nni_aio_set_prov_data(nni_aio *, void *);
@@ -186,7 +186,7 @@ extern void nni_aio_completions_run(nni_aio_completions *);
// appropriate) to the completion list. This should be done while the
// appropriate lock is held. The aio must not be scheduled.
extern void nni_aio_completions_add(
- nni_aio_completions *, nni_aio *, int, size_t);
+ nni_aio_completions *, nni_aio *, nng_err, size_t);
extern int nni_aio_sys_init(nng_init_params *);
extern bool nni_aio_sys_drain(void);
@@ -206,7 +206,7 @@ struct nng_aio {
size_t a_count; // Bytes transferred (I/O only)
nni_time a_expire; // Absolute timeout
nni_duration a_timeout; // Relative timeout
- int a_result; // Result code (nng_errno)
+ nng_err a_result; // Result code (nng_errno)
bool a_stop; // Shutting down (no new operations)
bool a_sleep; // Sleeping with no action
bool a_expire_ok; // Expire from sleep is ok
diff --git a/src/nng.c b/src/nng.c
index 002f29f8..d9b111a8 100644
--- a/src/nng.c
+++ b/src/nng.c
@@ -1234,7 +1234,7 @@ nng_device(nng_socket s1, nng_socket s2)
}
static const struct {
- int code;
+ nng_err code;
const char *msg;
} nni_errors[] = {
// clang-format off
@@ -1276,7 +1276,7 @@ static const struct {
// Misc.
const char *
-nng_strerror(int num)
+nng_strerror(nng_err num)
{
static char unknownerrbuf[32];
for (int i = 0; nni_errors[i].msg != NULL; i++) {
@@ -1859,7 +1859,7 @@ nng_sleep_aio(nng_duration ms, nng_aio *aio)
nni_sleep_aio(ms, aio);
}
-int
+nng_err
nng_aio_result(nng_aio *aio)
{
return (nni_aio_result(aio));
@@ -1890,7 +1890,7 @@ nng_aio_busy(nng_aio *aio)
}
void
-nng_aio_abort(nng_aio *aio, int err_code)
+nng_aio_abort(nng_aio *aio, nng_err err_code)
{
nni_aio_abort(aio, err_code);
}
diff --git a/src/supplemental/http/http_public.c b/src/supplemental/http/http_public.c
index 9c4145fd..1152729d 100644
--- a/src/supplemental/http/http_public.c
+++ b/src/supplemental/http/http_public.c
@@ -27,7 +27,7 @@ nng_http_get_header(nng_http *conn, const char *key)
#endif
}
-int
+nng_err
nng_http_set_header(nng_http *conn, const char *key, const char *val)
{
#ifdef NNG_SUPP_HTTP
@@ -40,7 +40,7 @@ nng_http_set_header(nng_http *conn, const char *key, const char *val)
#endif
}
-int
+nng_err
nng_http_add_header(nng_http *conn, const char *key, const char *val)
{
#ifdef NNG_SUPP_HTTP
@@ -61,7 +61,6 @@ nng_http_del_header(nng_http *conn, const char *key)
#else
NNI_ARG_UNUSED(conn);
NNI_ARG_UNUSED(key);
- return (NNG_ENOTSUP);
#endif
}
@@ -78,7 +77,7 @@ nng_http_set_body(nng_http *conn, void *data, size_t sz)
#endif
}
-int
+nng_err
nng_http_copy_body(nng_http *conn, const void *data, size_t len)
{
#ifdef NNG_SUPP_HTTP
@@ -114,7 +113,7 @@ nng_http_get_uri(nng_http *conn)
#endif
}
-int
+nng_err
nng_http_set_uri(nng_http *conn, const char *uri, const char *query)
{
#ifdef NNG_SUPP_HTTP
@@ -174,7 +173,7 @@ nng_http_get_reason(nng_http *conn)
#endif
}
-int
+nng_err
nng_http_set_version(nng_http *conn, const char *version)
{
#ifdef NNG_SUPP_HTTP
@@ -295,7 +294,7 @@ nng_http_read_response(nng_http *conn, nng_aio *aio)
#endif
}
-int
+nng_err
nng_http_handler_alloc(
nng_http_handler **hp, const char *uri, nng_http_handler_func cb)
{
@@ -319,7 +318,7 @@ nng_http_handler_free(nng_http_handler *h)
#endif
}
-int
+nng_err
nng_http_handler_alloc_file(
nng_http_handler **hp, const char *uri, const char *path)
{
@@ -333,7 +332,7 @@ nng_http_handler_alloc_file(
#endif
}
-int
+nng_err
nng_http_handler_alloc_directory(
nng_http_handler **hp, const char *uri, const char *path)
{
@@ -347,7 +346,7 @@ nng_http_handler_alloc_directory(
#endif
}
-int
+nng_err
nng_http_handler_alloc_redirect(
nng_http_handler **hp, const char *uri, uint16_t status, const char *where)
{
@@ -362,7 +361,7 @@ nng_http_handler_alloc_redirect(
#endif
}
-int
+nng_err
nng_http_handler_alloc_static(nng_http_handler **hp, const char *uri,
const void *data, size_t size, const char *ctype)
{
@@ -434,7 +433,7 @@ nng_http_handler_set_data(nng_http_handler *h, void *dat, void (*dtor)(void *))
#endif
}
-int
+nng_err
nng_http_server_hold(nng_http_server **srvp, const nng_url *url)
{
#ifdef NNG_SUPP_HTTP
@@ -456,7 +455,7 @@ nng_http_server_release(nng_http_server *srv)
#endif
}
-int
+nng_err
nng_http_server_start(nng_http_server *srv)
{
#ifdef NNG_SUPP_HTTP
@@ -477,7 +476,7 @@ nng_http_server_stop(nng_http_server *srv)
#endif
}
-int
+nng_err
nng_http_server_add_handler(nng_http_server *srv, nng_http_handler *h)
{
#ifdef NNG_SUPP_HTTP
@@ -489,7 +488,7 @@ nng_http_server_add_handler(nng_http_server *srv, nng_http_handler *h)
#endif
}
-int
+nng_err
nng_http_server_del_handler(nng_http_server *srv, nng_http_handler *h)
{
#ifdef NNG_SUPP_HTTP
@@ -501,7 +500,7 @@ nng_http_server_del_handler(nng_http_server *srv, nng_http_handler *h)
#endif
}
-int
+nng_err
nng_http_server_set_error_page(
nng_http_server *srv, uint16_t code, const char *body)
{
@@ -515,7 +514,7 @@ nng_http_server_set_error_page(
#endif
}
-int
+nng_err
nng_http_server_set_tls(nng_http_server *srv, nng_tls_config *cfg)
{
#if defined(NNG_SUPP_HTTP) && defined(NNG_SUPP_TLS)
@@ -527,7 +526,7 @@ nng_http_server_set_tls(nng_http_server *srv, nng_tls_config *cfg)
#endif
}
-int
+nng_err
nng_http_server_get_tls(nng_http_server *srv, nng_tls_config **cfg)
{
#if defined(NNG_SUPP_HTTP) && defined(NNG_SUPP_TLS)
@@ -539,7 +538,7 @@ nng_http_server_get_tls(nng_http_server *srv, nng_tls_config **cfg)
#endif
}
-int
+nng_err
nng_http_server_get_addr(nng_http_server *srv, nng_sockaddr *addr)
{
#ifdef NNG_SUPP_HTTP
@@ -555,7 +554,7 @@ nng_http_server_get_addr(nng_http_server *srv, nng_sockaddr *addr)
#endif
}
-int
+nng_err
nng_http_server_error(nng_http_server *srv, nng_http *conn)
{
#ifdef NNG_SUPP_HTTP
@@ -567,7 +566,7 @@ nng_http_server_error(nng_http_server *srv, nng_http *conn)
#endif
}
-int
+nng_err
nng_http_hijack(nng_http *conn)
{
#ifdef NNG_SUPP_HTTP
@@ -578,7 +577,7 @@ nng_http_hijack(nng_http *conn)
#endif
}
-int
+nng_err
nng_http_client_alloc(nng_http_client **clip, const nng_url *url)
{
#ifdef NNG_SUPP_HTTP
@@ -600,7 +599,7 @@ nng_http_client_free(nng_http_client *cli)
#endif
}
-int
+nng_err
nng_http_client_set_tls(nng_http_client *cli, nng_tls_config *cfg)
{
#if defined(NNG_SUPP_HTTP) && defined(NNG_SUPP_TLS)
@@ -612,7 +611,7 @@ nng_http_client_set_tls(nng_http_client *cli, nng_tls_config *cfg)
#endif
}
-int
+nng_err
nng_http_client_get_tls(nng_http_client *cli, nng_tls_config **cfgp)
{
#if defined(NNG_SUPP_HTTP) && defined(NNG_SUPP_TLS)