diff options
| author | Garrett D'Amore <garrett@damore.org> | 2025-04-27 23:35:25 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2025-04-27 23:35:25 -0700 |
| commit | 7bb5ab9c4f70c9fa0a67a22c4aee83b0109318c4 (patch) | |
| tree | 5a3036d609404ee5218b6189a89799e70f4623df /src/sp/protocol | |
| parent | 70ae513e4dda50864f7d45b6676549ed5246144d (diff) | |
| download | nng-7bb5ab9c4f70c9fa0a67a22c4aee83b0109318c4.tar.gz nng-7bb5ab9c4f70c9fa0a67a22c4aee83b0109318c4.tar.bz2 nng-7bb5ab9c4f70c9fa0a67a22c4aee83b0109318c4.zip | |
Converted property functions to use nng_err.
Diffstat (limited to 'src/sp/protocol')
| -rw-r--r-- | src/sp/protocol/bus0/bus.c | 22 | ||||
| -rw-r--r-- | src/sp/protocol/pair0/pair.c | 20 | ||||
| -rw-r--r-- | src/sp/protocol/pair1/pair.c | 33 | ||||
| -rw-r--r-- | src/sp/protocol/pair1/pair1_poly.c | 11 | ||||
| -rw-r--r-- | src/sp/protocol/pipeline0/pull.c | 2 | ||||
| -rw-r--r-- | src/sp/protocol/pipeline0/push.c | 10 | ||||
| -rw-r--r-- | src/sp/protocol/pubsub0/pub.c | 10 | ||||
| -rw-r--r-- | src/sp/protocol/pubsub0/sub.c | 40 | ||||
| -rw-r--r-- | src/sp/protocol/reqrep0/rep.c | 13 | ||||
| -rw-r--r-- | src/sp/protocol/reqrep0/req.c | 31 | ||||
| -rw-r--r-- | src/sp/protocol/reqrep0/xrep.c | 9 | ||||
| -rw-r--r-- | src/sp/protocol/reqrep0/xreq.c | 9 | ||||
| -rw-r--r-- | src/sp/protocol/survey0/respond.c | 13 | ||||
| -rw-r--r-- | src/sp/protocol/survey0/survey.c | 20 | ||||
| -rw-r--r-- | src/sp/protocol/survey0/xrespond.c | 9 | ||||
| -rw-r--r-- | src/sp/protocol/survey0/xsurvey.c | 9 |
16 files changed, 135 insertions, 126 deletions
diff --git a/src/sp/protocol/bus0/bus.c b/src/sp/protocol/bus0/bus.c index 13abfd6b..4f946365 100644 --- a/src/sp/protocol/bus0/bus.c +++ b/src/sp/protocol/bus0/bus.c @@ -360,7 +360,7 @@ again: nni_aio_finish(aio, 0, nni_msg_len(msg)); } -static int +static nng_err bus0_sock_get_send_fd(void *arg, int *fdp) { bus0_sock *sock = arg; @@ -369,7 +369,7 @@ bus0_sock_get_send_fd(void *arg, int *fdp) return (nni_pollable_getfd(&sock->can_send, fdp)); } -static int +static nng_err bus0_sock_get_recv_fd(void *arg, int *fdp) { bus0_sock *s = arg; @@ -377,7 +377,7 @@ bus0_sock_get_recv_fd(void *arg, int *fdp) return (nni_pollable_getfd(&s->can_recv, fdp)); } -static int +static nng_err bus0_sock_get_recv_buf_len(void *arg, void *buf, size_t *szp, nni_type t) { bus0_sock *s = arg; @@ -389,7 +389,7 @@ bus0_sock_get_recv_buf_len(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_int(val, buf, szp, t)); } -static int +static nng_err bus0_sock_get_send_buf_len(void *arg, void *buf, size_t *szp, nni_type t) { bus0_sock *s = arg; @@ -400,14 +400,14 @@ bus0_sock_get_send_buf_len(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_int(val, buf, szp, t)); } -static int +static nng_err bus0_sock_set_recv_buf_len(void *arg, const void *buf, size_t sz, nni_type t) { bus0_sock *s = arg; int val; - int rv; + nng_err rv; - if ((rv = nni_copyin_int(&val, buf, sz, 1, 8192, t)) != 0) { + if ((rv = nni_copyin_int(&val, buf, sz, 1, 8192, t)) != NNG_OK) { return (rv); } nni_mtx_lock(&s->mtx); @@ -417,18 +417,18 @@ bus0_sock_set_recv_buf_len(void *arg, const void *buf, size_t sz, nni_type t) } nni_mtx_unlock(&s->mtx); - return (0); + return (NNG_OK); } -static int +static nng_err bus0_sock_set_send_buf_len(void *arg, const void *buf, size_t sz, nni_type t) { bus0_sock *s = arg; bus0_pipe *p; int val; - int rv; + nng_err rv; - if ((rv = nni_copyin_int(&val, buf, sz, 1, 8192, t)) != 0) { + if ((rv = nni_copyin_int(&val, buf, sz, 1, 8192, t)) != NNG_OK) { return (rv); } diff --git a/src/sp/protocol/pair0/pair.c b/src/sp/protocol/pair0/pair.c index 5dc7f67a..89bff7ce 100644 --- a/src/sp/protocol/pair0/pair.c +++ b/src/sp/protocol/pair0/pair.c @@ -430,14 +430,14 @@ pair0_sock_recv(void *arg, nni_aio *aio) nni_mtx_unlock(&s->mtx); } -static int +static nng_err pair0_set_send_buf_len(void *arg, const void *buf, size_t sz, nni_type t) { pair0_sock *s = arg; int val; - int rv; + nng_err rv; - if ((rv = nni_copyin_int(&val, buf, sz, 0, 8192, t)) != 0) { + if ((rv = nni_copyin_int(&val, buf, sz, 0, 8192, t)) != NNG_OK) { return (rv); } nni_mtx_lock(&s->mtx); @@ -452,7 +452,7 @@ pair0_set_send_buf_len(void *arg, const void *buf, size_t sz, nni_type t) return (rv); } -static int +static nng_err pair0_get_send_buf_len(void *arg, void *buf, size_t *szp, nni_opt_type t) { pair0_sock *s = arg; @@ -465,14 +465,14 @@ pair0_get_send_buf_len(void *arg, void *buf, size_t *szp, nni_opt_type t) return (nni_copyout_int(val, buf, szp, t)); } -static int +static nng_err pair0_set_recv_buf_len(void *arg, const void *buf, size_t sz, nni_type t) { pair0_sock *s = arg; int val; - int rv; + nng_err rv; - if ((rv = nni_copyin_int(&val, buf, sz, 0, 8192, t)) != 0) { + if ((rv = nni_copyin_int(&val, buf, sz, 0, 8192, t)) != NNG_OK) { return (rv); } nni_mtx_lock(&s->mtx); @@ -487,7 +487,7 @@ pair0_set_recv_buf_len(void *arg, const void *buf, size_t sz, nni_type t) return (rv); } -static int +static nng_err pair0_get_recv_buf_len(void *arg, void *buf, size_t *szp, nni_opt_type t) { pair0_sock *s = arg; @@ -500,7 +500,7 @@ pair0_get_recv_buf_len(void *arg, void *buf, size_t *szp, nni_opt_type t) return (nni_copyout_int(val, buf, szp, t)); } -static int +static nng_err pair0_sock_get_recv_fd(void *arg, int *fdp) { pair0_sock *s = arg; @@ -508,7 +508,7 @@ pair0_sock_get_recv_fd(void *arg, int *fdp) return (nni_pollable_getfd(&s->readable, fdp)); } -static int +static nng_err pair0_sock_get_send_fd(void *arg, int *fdp) { pair0_sock *s = arg; diff --git a/src/sp/protocol/pair1/pair.c b/src/sp/protocol/pair1/pair.c index 35e87b7b..3aa9b4c7 100644 --- a/src/sp/protocol/pair1/pair.c +++ b/src/sp/protocol/pair1/pair.c @@ -467,21 +467,22 @@ pair1_sock_close(void *arg) nni_mtx_unlock(&s->mtx); } -static int +static nng_err pair1_sock_set_max_ttl(void *arg, const void *buf, size_t sz, nni_opt_type t) { pair1_sock *s = arg; - int rv; + nng_err rv; int ttl; - if ((rv = nni_copyin_int(&ttl, buf, sz, 1, NNI_MAX_MAX_TTL, t)) == 0) { + if ((rv = nni_copyin_int(&ttl, buf, sz, 1, NNI_MAX_MAX_TTL, t)) == + NNG_OK) { nni_atomic_set(&s->ttl, ttl); } return (rv); } -static int +static nng_err pair1_sock_get_max_ttl(void *arg, void *buf, size_t *szp, nni_opt_type t) { pair1_sock *s = arg; @@ -489,11 +490,11 @@ pair1_sock_get_max_ttl(void *arg, void *buf, size_t *szp, nni_opt_type t) } #ifdef NNG_TEST_LIB -static int +static nng_err pair1_set_test_inject_header(void *arg, const void *buf, size_t sz, nni_type t) { pair1_sock *s = arg; - int rv; + nng_err rv; nni_mtx_lock(&s->mtx); rv = nni_copyin_bool(&s->inject_header, buf, sz, t); nni_mtx_unlock(&s->mtx); @@ -646,14 +647,14 @@ pair1_sock_recv(void *arg, nni_aio *aio) nni_mtx_unlock(&s->mtx); } -static int +static nng_err pair1_set_send_buf_len(void *arg, const void *buf, size_t sz, nni_type t) { pair1_sock *s = arg; int val; - int rv; + nng_err rv; - if ((rv = nni_copyin_int(&val, buf, sz, 0, 8192, t)) != 0) { + if ((rv = nni_copyin_int(&val, buf, sz, 0, 8192, t)) != NNG_OK) { return (rv); } nni_mtx_lock(&s->mtx); @@ -668,7 +669,7 @@ pair1_set_send_buf_len(void *arg, const void *buf, size_t sz, nni_type t) return (rv); } -static int +static nng_err pair1_get_send_buf_len(void *arg, void *buf, size_t *szp, nni_opt_type t) { pair1_sock *s = arg; @@ -681,14 +682,14 @@ pair1_get_send_buf_len(void *arg, void *buf, size_t *szp, nni_opt_type t) return (nni_copyout_int(val, buf, szp, t)); } -static int +static nng_err pair1_set_recv_buf_len(void *arg, const void *buf, size_t sz, nni_type t) { pair1_sock *s = arg; int val; - int rv; + nng_err rv; - if ((rv = nni_copyin_int(&val, buf, sz, 0, 8192, t)) != 0) { + if ((rv = nni_copyin_int(&val, buf, sz, 0, 8192, t)) != NNG_OK) { return (rv); } nni_mtx_lock(&s->mtx); @@ -703,7 +704,7 @@ pair1_set_recv_buf_len(void *arg, const void *buf, size_t sz, nni_type t) return (rv); } -static int +static nng_err pair1_get_recv_buf_len(void *arg, void *buf, size_t *szp, nni_opt_type t) { pair1_sock *s = arg; @@ -716,7 +717,7 @@ pair1_get_recv_buf_len(void *arg, void *buf, size_t *szp, nni_opt_type t) return (nni_copyout_int(val, buf, szp, t)); } -static int +static nng_err pair1_sock_get_recv_fd(void *arg, int *fdp) { pair1_sock *s = arg; @@ -724,7 +725,7 @@ pair1_sock_get_recv_fd(void *arg, int *fdp) return (nni_pollable_getfd(&s->readable, fdp)); } -static int +static nng_err pair1_sock_get_send_fd(void *arg, int *fdp) { pair1_sock *s = arg; diff --git a/src/sp/protocol/pair1/pair1_poly.c b/src/sp/protocol/pair1/pair1_poly.c index 0e8a93f3..af3ede3b 100644 --- a/src/sp/protocol/pair1/pair1_poly.c +++ b/src/sp/protocol/pair1/pair1_poly.c @@ -443,28 +443,29 @@ pair1poly_sock_close(void *arg) nni_aio_close(&s->aio_get); } -static int +static nng_err pair1poly_set_max_ttl(void *arg, const void *buf, size_t sz, nni_opt_type t) { pair1poly_sock *s = arg; - int rv; + nng_err rv; int ttl; - if ((rv = nni_copyin_int(&ttl, buf, sz, 1, NNI_MAX_MAX_TTL, t)) == 0) { + if ((rv = nni_copyin_int(&ttl, buf, sz, 1, NNI_MAX_MAX_TTL, t)) == + NNG_OK) { nni_atomic_set(&s->ttl, ttl); } return (rv); } -static int +static nng_err pair1poly_get_max_ttl(void *arg, void *buf, size_t *szp, nni_opt_type t) { pair1poly_sock *s = arg; return (nni_copyout_int(nni_atomic_get(&s->ttl), buf, szp, t)); } -static int +static nng_err pair1poly_get_poly(void *arg, void *buf, size_t *szp, nni_opt_type t) { NNI_ARG_UNUSED(arg); diff --git a/src/sp/protocol/pipeline0/pull.c b/src/sp/protocol/pipeline0/pull.c index d808180a..559935b0 100644 --- a/src/sp/protocol/pipeline0/pull.c +++ b/src/sp/protocol/pipeline0/pull.c @@ -245,7 +245,7 @@ pull0_sock_recv(void *arg, nni_aio *aio) nni_mtx_unlock(&s->m); } -static int +static nng_err pull0_sock_get_recv_fd(void *arg, int *fdp) { pull0_sock *s = arg; diff --git a/src/sp/protocol/pipeline0/push.c b/src/sp/protocol/pipeline0/push.c index 4260f333..cd710480 100644 --- a/src/sp/protocol/pipeline0/push.c +++ b/src/sp/protocol/pipeline0/push.c @@ -321,14 +321,14 @@ push0_sock_recv(void *arg, nni_aio *aio) nni_aio_finish_error(aio, NNG_ENOTSUP); } -static int +static nng_err push0_set_send_buf_len(void *arg, const void *buf, size_t sz, nni_type t) { push0_sock *s = arg; int val; - int rv; + nng_err rv; - if ((rv = nni_copyin_int(&val, buf, sz, 0, 8192, t)) != 0) { + if ((rv = nni_copyin_int(&val, buf, sz, 0, 8192, t)) != NNG_OK) { return (rv); } nni_mtx_lock(&s->m); @@ -343,7 +343,7 @@ push0_set_send_buf_len(void *arg, const void *buf, size_t sz, nni_type t) return (rv); } -static int +static nng_err push0_get_send_buf_len(void *arg, void *buf, size_t *szp, nni_opt_type t) { push0_sock *s = arg; @@ -356,7 +356,7 @@ push0_get_send_buf_len(void *arg, void *buf, size_t *szp, nni_opt_type t) return (nni_copyout_int(val, buf, szp, t)); } -static int +static nng_err push0_sock_get_send_fd(void *arg, int *fdp) { push0_sock *s = arg; diff --git a/src/sp/protocol/pubsub0/pub.c b/src/sp/protocol/pubsub0/pub.c index db449cde..5104162b 100644 --- a/src/sp/protocol/pubsub0/pub.c +++ b/src/sp/protocol/pubsub0/pub.c @@ -249,7 +249,7 @@ pub0_sock_send(void *arg, nni_aio *aio) nni_aio_finish(aio, 0, len); } -static int +static nng_err pub0_sock_get_sendfd(void *arg, int *fdp) { pub0_sock *sock = arg; @@ -259,15 +259,15 @@ pub0_sock_get_sendfd(void *arg, int *fdp) return (nni_pollable_getfd(&sock->sendable, fdp)); } -static int +static nng_err pub0_sock_set_sendbuf(void *arg, const void *buf, size_t sz, nni_type t) { pub0_sock *sock = arg; pub0_pipe *p; int val; - int rv; + nng_err rv; - if ((rv = nni_copyin_int(&val, buf, sz, 1, 8192, t)) != 0) { + if ((rv = nni_copyin_int(&val, buf, sz, 1, 8192, t)) != NNG_OK) { return (rv); } @@ -287,7 +287,7 @@ pub0_sock_set_sendbuf(void *arg, const void *buf, size_t sz, nni_type t) return (rv); } -static int +static nng_err pub0_sock_get_sendbuf(void *arg, void *buf, size_t *szp, nni_type t) { pub0_sock *sock = arg; diff --git a/src/sp/protocol/pubsub0/sub.c b/src/sp/protocol/pubsub0/sub.c index 6744e909..c426d46c 100644 --- a/src/sp/protocol/pubsub0/sub.c +++ b/src/sp/protocol/pubsub0/sub.c @@ -400,7 +400,7 @@ sub0_recv_cb(void *arg) nni_pipe_recv(p->pipe, &p->aio_recv); } -static int +static nng_err sub0_ctx_get_recv_buf_len(void *arg, void *buf, size_t *szp, nni_type t) { sub0_ctx *ctx = arg; @@ -413,15 +413,15 @@ sub0_ctx_get_recv_buf_len(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_int(val, buf, szp, t)); } -static int +static nng_err sub0_ctx_set_recv_buf_len(void *arg, const void *buf, size_t sz, nni_type t) { sub0_ctx *ctx = arg; sub0_sock *sock = ctx->sock; int val; - int rv; + nng_err rv; - if ((rv = nni_copyin_int(&val, buf, sz, 1, 8192, t)) != 0) { + if ((rv = nni_copyin_int(&val, buf, sz, 1, 8192, t)) != NNG_OK) { return (rv); } nni_mtx_lock(&sock->lk); @@ -436,7 +436,7 @@ sub0_ctx_set_recv_buf_len(void *arg, const void *buf, size_t sz, nni_type t) sock->recv_buf_len = (size_t) val; } nni_mtx_unlock(&sock->lk); - return (0); + return (NNG_OK); } // For now, we maintain subscriptions on a sorted linked list. As we do not @@ -444,7 +444,7 @@ sub0_ctx_set_recv_buf_len(void *arg, const void *buf, size_t sz, nni_type t) // really O(n), we think this is acceptable. In the future we might decide // to replace this with a patricia trie, like old nanomsg had. -static int +static nng_err sub0_ctx_subscribe(sub0_ctx *ctx, const void *buf, size_t sz) { sub0_sock *sock = ctx->sock; @@ -459,7 +459,7 @@ sub0_ctx_subscribe(sub0_ctx *ctx, const void *buf, size_t sz) if (memcmp(topic->buf, buf, sz) == 0) { // Already have it. nni_mtx_unlock(&sock->lk); - return (0); + return (NNG_OK); } } if ((new_topic = NNI_ALLOC_STRUCT(new_topic)) == NULL) { @@ -477,10 +477,10 @@ sub0_ctx_subscribe(sub0_ctx *ctx, const void *buf, size_t sz) new_topic->len = sz; nni_list_append(&ctx->topics, new_topic); nni_mtx_unlock(&sock->lk); - return (0); + return (NNG_OK); } -static int +static nng_err sub0_ctx_unsubscribe(sub0_ctx *ctx, const void *buf, size_t sz) { sub0_sock *sock = ctx->sock; @@ -521,10 +521,10 @@ sub0_ctx_unsubscribe(sub0_ctx *ctx, const void *buf, size_t sz) nni_free(topic->buf, topic->len); NNI_FREE_STRUCT(topic); - return (0); + return (NNG_OK); } -static int +static nng_err sub0_ctx_get_prefer_new(void *arg, void *buf, size_t *szp, nni_type t) { sub0_ctx *ctx = arg; @@ -538,15 +538,15 @@ sub0_ctx_get_prefer_new(void *arg, void *buf, size_t *szp, nni_type t) return (nni_copyout_bool(val, buf, szp, t)); } -static int +static nng_err sub0_ctx_set_prefer_new(void *arg, const void *buf, size_t sz, nni_type t) { sub0_ctx *ctx = arg; sub0_sock *sock = ctx->sock; bool val; - int rv; + nng_err rv; - if ((rv = nni_copyin_bool(&val, buf, sz, t)) != 0) { + if ((rv = nni_copyin_bool(&val, buf, sz, t)) != NNG_OK) { return (rv); } @@ -557,7 +557,7 @@ sub0_ctx_set_prefer_new(void *arg, const void *buf, size_t sz, nni_type t) } nni_mtx_unlock(&sock->lk); - return (0); + return (NNG_OK); } static nni_option sub0_ctx_options[] = { @@ -591,7 +591,7 @@ sub0_sock_recv(void *arg, nni_aio *aio) sub0_ctx_recv(&sock->master, aio); } -static int +static nng_err sub0_sock_get_recv_fd(void *arg, int *fdp) { sub0_sock *sock = arg; @@ -599,28 +599,28 @@ sub0_sock_get_recv_fd(void *arg, int *fdp) return (nni_pollable_getfd(&sock->readable, fdp)); } -static int +static nng_err sub0_sock_get_recv_buf_len(void *arg, void *buf, size_t *szp, nni_type t) { sub0_sock *sock = arg; return (sub0_ctx_get_recv_buf_len(&sock->master, buf, szp, t)); } -static int +static nng_err sub0_sock_set_recv_buf_len(void *arg, const void *buf, size_t sz, nni_type t) { sub0_sock *sock = arg; return (sub0_ctx_set_recv_buf_len(&sock->master, buf, sz, t)); } -static int +static nng_err sub0_sock_get_prefer_new(void *arg, void *buf, size_t *szp, nni_type t) { sub0_sock *sock = arg; return (sub0_ctx_get_prefer_new(&sock->master, buf, szp, t)); } -static int +static nng_err sub0_sock_set_prefer_new(void *arg, const void *buf, size_t sz, nni_type t) { sub0_sock *sock = arg; diff --git a/src/sp/protocol/reqrep0/rep.c b/src/sp/protocol/reqrep0/rep.c index e84440a7..6df65df3 100644 --- a/src/sp/protocol/reqrep0/rep.c +++ b/src/sp/protocol/reqrep0/rep.c @@ -567,20 +567,21 @@ drop: nni_pipe_recv(p->pipe, &p->aio_recv); } -static int +static nng_err rep0_sock_set_max_ttl(void *arg, const void *buf, size_t sz, nni_opt_type t) { rep0_sock *s = arg; int ttl; - int rv; + nng_err rv; - if ((rv = nni_copyin_int(&ttl, buf, sz, 1, NNI_MAX_MAX_TTL, t)) == 0) { + if ((rv = nni_copyin_int(&ttl, buf, sz, 1, NNI_MAX_MAX_TTL, t)) == + NNG_OK) { nni_atomic_set(&s->ttl, ttl); } return (rv); } -static int +static nng_err rep0_sock_get_max_ttl(void *arg, void *buf, size_t *szp, nni_opt_type t) { rep0_sock *s = arg; @@ -588,7 +589,7 @@ rep0_sock_get_max_ttl(void *arg, void *buf, size_t *szp, nni_opt_type t) return (nni_copyout_int(nni_atomic_get(&s->ttl), buf, szp, t)); } -static int +static nng_err rep0_sock_get_sendfd(void *arg, int *fdp) { rep0_sock *s = arg; @@ -596,7 +597,7 @@ rep0_sock_get_sendfd(void *arg, int *fdp) return (nni_pollable_getfd(&s->writable, fdp)); } -static int +static nng_err rep0_sock_get_recvfd(void *arg, int *fdp) { rep0_sock *s = arg; diff --git a/src/sp/protocol/reqrep0/req.c b/src/sp/protocol/reqrep0/req.c index 52f97d3a..85c2dfa4 100644 --- a/src/sp/protocol/reqrep0/req.c +++ b/src/sp/protocol/reqrep0/req.c @@ -465,14 +465,14 @@ req0_ctx_fini(void *arg) nni_mtx_unlock(&s->mtx); } -static int +static nng_err req0_ctx_set_resend_time(void *arg, const void *buf, size_t sz, nni_opt_type t) { req0_ctx *ctx = arg; return (nni_copyin_ms(&ctx->retry, buf, sz, t)); } -static int +static nng_err req0_ctx_get_resend_time(void *arg, void *buf, size_t *szp, nni_opt_type t) { req0_ctx *ctx = arg; @@ -777,52 +777,53 @@ req0_sock_recv(void *arg, nni_aio *aio) req0_ctx_recv(&s->master, aio); } -static int +static nng_err req0_sock_set_max_ttl(void *arg, const void *buf, size_t sz, nni_opt_type t) { req0_sock *s = arg; int ttl; - int rv; - if ((rv = nni_copyin_int(&ttl, buf, sz, 1, NNI_MAX_MAX_TTL, t)) == 0) { + nng_err rv; + if ((rv = nni_copyin_int(&ttl, buf, sz, 1, NNI_MAX_MAX_TTL, t)) == + NNG_OK) { nni_atomic_set(&s->ttl, ttl); } return (rv); } -static int +static nng_err req0_sock_get_max_ttl(void *arg, void *buf, size_t *szp, nni_opt_type t) { req0_sock *s = arg; return (nni_copyout_int(nni_atomic_get(&s->ttl), buf, szp, t)); } -static int +static nng_err req0_sock_set_resend_time( void *arg, const void *buf, size_t sz, nni_opt_type t) { req0_sock *s = arg; - int rv; + nng_err rv; rv = req0_ctx_set_resend_time(&s->master, buf, sz, t); s->retry = s->master.retry; return (rv); } -static int +static nng_err req0_sock_get_resend_time(void *arg, void *buf, size_t *szp, nni_opt_type t) { req0_sock *s = arg; return (req0_ctx_get_resend_time(&s->master, buf, szp, t)); } -static int +static nng_err req0_sock_set_resend_tick( void *arg, const void *buf, size_t sz, nni_opt_type t) { req0_sock *s = arg; nng_duration tick; - int rv; + nng_err rv; - if ((rv = nni_copyin_ms(&tick, buf, sz, t)) == 0) { + if ((rv = nni_copyin_ms(&tick, buf, sz, t)) == NNG_OK) { nni_mtx_lock(&s->mtx); s->retry_tick = tick; nni_mtx_unlock(&s->mtx); @@ -830,7 +831,7 @@ req0_sock_set_resend_tick( return (rv); } -static int +static nng_err req0_sock_get_resend_tick(void *arg, void *buf, size_t *szp, nni_opt_type t) { req0_sock *s = arg; @@ -842,7 +843,7 @@ req0_sock_get_resend_tick(void *arg, void *buf, size_t *szp, nni_opt_type t) return (nni_copyout_ms(tick, buf, szp, t)); } -static int +static nng_err req0_sock_get_send_fd(void *arg, int *fdp) { req0_sock *s = arg; @@ -850,7 +851,7 @@ req0_sock_get_send_fd(void *arg, int *fdp) return (nni_pollable_getfd(&s->writable, fdp)); } -static int +static nng_err req0_sock_get_recv_fd(void *arg, int *fdp) { req0_sock *s = arg; diff --git a/src/sp/protocol/reqrep0/xrep.c b/src/sp/protocol/reqrep0/xrep.c index 1a5f6e24..fe6c9fde 100644 --- a/src/sp/protocol/reqrep0/xrep.c +++ b/src/sp/protocol/reqrep0/xrep.c @@ -353,19 +353,20 @@ xrep0_pipe_putq_cb(void *arg) nni_pipe_recv(p->pipe, &p->aio_recv); } -static int +static nng_err xrep0_sock_set_maxttl(void *arg, const void *buf, size_t sz, nni_opt_type t) { xrep0_sock *s = arg; int ttl; - int rv; - if ((rv = nni_copyin_int(&ttl, buf, sz, 1, NNI_MAX_MAX_TTL, t)) == 0) { + nng_err rv; + if ((rv = nni_copyin_int(&ttl, buf, sz, 1, NNI_MAX_MAX_TTL, t)) == + NNG_OK) { nni_atomic_set(&s->ttl, ttl); } return (rv); } -static int +static nng_err xrep0_sock_get_maxttl(void *arg, void *buf, size_t *szp, nni_opt_type t) { xrep0_sock *s = arg; diff --git a/src/sp/protocol/reqrep0/xreq.c b/src/sp/protocol/reqrep0/xreq.c index 2bf3b95e..f80391dd 100644 --- a/src/sp/protocol/reqrep0/xreq.c +++ b/src/sp/protocol/reqrep0/xreq.c @@ -256,19 +256,20 @@ xreq0_sock_recv(void *arg, nni_aio *aio) nni_msgq_aio_get(s->urq, aio); } -static int +static nng_err xreq0_sock_set_max_ttl(void *arg, const void *buf, size_t sz, nni_opt_type t) { xreq0_sock *s = arg; int ttl; - int rv; - if ((rv = nni_copyin_int(&ttl, buf, sz, 1, NNI_MAX_MAX_TTL, t)) == 0) { + nng_err rv; + if ((rv = nni_copyin_int(&ttl, buf, sz, 1, NNI_MAX_MAX_TTL, t)) == + NNG_OK) { nni_atomic_set(&s->ttl, ttl); } return (rv); } -static int +static nng_err xreq0_sock_get_max_ttl(void *arg, void *buf, size_t *szp, nni_opt_type t) { xreq0_sock *s = arg; diff --git a/src/sp/protocol/survey0/respond.c b/src/sp/protocol/survey0/respond.c index ace2962a..f50ccb6b 100644 --- a/src/sp/protocol/survey0/respond.c +++ b/src/sp/protocol/survey0/respond.c @@ -557,27 +557,28 @@ drop: nni_pipe_recv(p->npipe, &p->aio_recv); } -static int +static nng_err resp0_sock_set_max_ttl(void *arg, const void *buf, size_t sz, nni_opt_type t) { resp0_sock *s = arg; int ttl; - int rv; + nng_err rv; - if ((rv = nni_copyin_int(&ttl, buf, sz, 1, NNI_MAX_MAX_TTL, t)) == 0) { + if ((rv = nni_copyin_int(&ttl, buf, sz, 1, NNI_MAX_MAX_TTL, t)) == + NNG_OK) { nni_atomic_set(&s->ttl, ttl); } return (rv); } -static int +static nng_err resp0_sock_get_max_ttl(void *arg, void *buf, size_t *szp, nni_opt_type t) { resp0_sock *s = arg; return (nni_copyout_int(nni_atomic_get(&s->ttl), buf, szp, t)); } -static int +static nng_err resp0_sock_get_sendfd(void *arg, int *fdp) { resp0_sock *s = arg; @@ -585,7 +586,7 @@ resp0_sock_get_sendfd(void *arg, int *fdp) return (nni_pollable_getfd(&s->writable, fdp)); } -static int +static nng_err resp0_sock_get_recvfd(void *arg, int *fdp) { resp0_sock *s = arg; diff --git a/src/sp/protocol/survey0/survey.c b/src/sp/protocol/survey0/survey.c index c64f0bb0..716375a9 100644 --- a/src/sp/protocol/survey0/survey.c +++ b/src/sp/protocol/survey0/survey.c @@ -462,20 +462,20 @@ surv0_pipe_recv_cb(void *arg) nni_pipe_recv(p->pipe, &p->aio_recv); } -static int +static nng_err surv0_ctx_set_survey_time( void *arg, const void *buf, size_t sz, nni_opt_type t) { surv0_ctx *ctx = arg; nng_duration expire; - int rv; - if ((rv = nni_copyin_ms(&expire, buf, sz, t)) == 0) { + nng_err rv; + if ((rv = nni_copyin_ms(&expire, buf, sz, t)) == NNG_OK) { nni_atomic_set(&ctx->survey_time, expire); } return (rv); } -static int +static nng_err surv0_ctx_get_survey_time(void *arg, void *buf, size_t *szp, nni_opt_type t) { surv0_ctx *ctx = arg; @@ -483,21 +483,21 @@ surv0_ctx_get_survey_time(void *arg, void *buf, size_t *szp, nni_opt_type t) nni_copyout_ms(nni_atomic_get(&ctx->survey_time), buf, szp, t)); } -static int +static nng_err surv0_sock_set_max_ttl(void *arg, const void *buf, size_t sz, nni_opt_type t) { surv0_sock *s = arg; return (nni_copyin_int(&s->ttl, buf, sz, 1, NNI_MAX_MAX_TTL, t)); } -static int +static nng_err surv0_sock_get_max_ttl(void *arg, void *buf, size_t *szp, nni_opt_type t) { surv0_sock *s = arg; return (nni_copyout_int(s->ttl, buf, szp, t)); } -static int +static nng_err surv0_sock_set_survey_time( void *arg, const void *buf, size_t sz, nni_opt_type t) { @@ -505,14 +505,14 @@ surv0_sock_set_survey_time( return (surv0_ctx_set_survey_time(&s->ctx, buf, sz, t)); } -static int +static nng_err surv0_sock_get_survey_time(void *arg, void *buf, size_t *szp, nni_opt_type t) { surv0_sock *s = arg; return (surv0_ctx_get_survey_time(&s->ctx, buf, szp, t)); } -static int +static nng_err surv0_sock_get_send_fd(void *arg, int *fdp) { surv0_sock *sock = arg; @@ -520,7 +520,7 @@ surv0_sock_get_send_fd(void *arg, int *fdp) return (nni_pollable_getfd(&sock->writable, fdp)); } -static int +static nng_err surv0_sock_get_recv_fd(void *arg, int *fdp) { surv0_sock *sock = arg; diff --git a/src/sp/protocol/survey0/xrespond.c b/src/sp/protocol/survey0/xrespond.c index ceddc118..0e04b516 100644 --- a/src/sp/protocol/survey0/xrespond.c +++ b/src/sp/protocol/survey0/xrespond.c @@ -334,19 +334,20 @@ xresp0_putq_cb(void *arg) nni_pipe_recv(p->npipe, &p->aio_recv); } -static int +static nng_err xresp0_sock_set_maxttl(void *arg, const void *buf, size_t sz, nni_opt_type t) { xresp0_sock *s = arg; int ttl; - int rv; - if ((rv = nni_copyin_int(&ttl, buf, sz, 1, NNI_MAX_MAX_TTL, t)) == 0) { + nng_err rv; + if ((rv = nni_copyin_int(&ttl, buf, sz, 1, NNI_MAX_MAX_TTL, t)) == + NNG_OK) { nni_atomic_set(&s->ttl, ttl); } return (rv); } -static int +static nng_err xresp0_sock_get_maxttl(void *arg, void *buf, size_t *szp, nni_opt_type t) { xresp0_sock *s = arg; diff --git a/src/sp/protocol/survey0/xsurvey.c b/src/sp/protocol/survey0/xsurvey.c index 2891fba5..3c78c392 100644 --- a/src/sp/protocol/survey0/xsurvey.c +++ b/src/sp/protocol/survey0/xsurvey.c @@ -272,19 +272,20 @@ xsurv0_recv_cb(void *arg) nni_msgq_aio_put(p->psock->urq, &p->aio_putq); } -static int +static nng_err xsurv0_sock_set_max_ttl(void *arg, const void *buf, size_t sz, nni_opt_type t) { xsurv0_sock *s = arg; int ttl; - int rv; - if ((rv = nni_copyin_int(&ttl, buf, sz, 1, NNI_MAX_MAX_TTL, t)) == 0) { + nng_err rv; + if ((rv = nni_copyin_int(&ttl, buf, sz, 1, NNI_MAX_MAX_TTL, t)) == + NNG_OK) { nni_atomic_set(&s->ttl, ttl); } return (rv); } -static int +static nng_err xsurv0_sock_get_max_ttl(void *arg, void *buf, size_t *szp, nni_opt_type t) { xsurv0_sock *s = arg; |
