aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/socket.c11
-rw-r--r--src/protocol/reqrep0/rep.c16
2 files changed, 8 insertions, 19 deletions
diff --git a/src/core/socket.c b/src/core/socket.c
index 5c28dbbb..8a14beb5 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -1273,15 +1273,14 @@ nni_ctx_getopt(nni_ctx *ctx, const char *opt, void *v, size_t *szp, int typ)
{
nni_sock * sock = ctx->c_sock;
nni_proto_ctx_option *co;
- int rv;
+ int rv = NNG_ENOTSUP;
nni_mtx_lock(&sock->s_mx);
if (strcmp(opt, NNG_OPT_RECVTIMEO) == 0) {
rv = nni_copyout_ms(ctx->c_rcvtimeo, v, szp, typ);
} else if (strcmp(opt, NNG_OPT_SENDTIMEO) == 0) {
rv = nni_copyout_ms(ctx->c_sndtimeo, v, szp, typ);
- } else {
- rv = NNG_ENOTSUP;
+ } else if (ctx->c_ops.ctx_options != NULL) {
for (co = ctx->c_ops.ctx_options; co->co_name != NULL; co++) {
if (strcmp(opt, co->co_name) != 0) {
continue;
@@ -1294,7 +1293,6 @@ nni_ctx_getopt(nni_ctx *ctx, const char *opt, void *v, size_t *szp, int typ)
break;
}
}
-
nni_mtx_unlock(&sock->s_mx);
return (rv);
}
@@ -1305,15 +1303,14 @@ nni_ctx_setopt(
{
nni_sock * sock = ctx->c_sock;
nni_proto_ctx_option *co;
- int rv;
+ int rv = NNG_ENOTSUP;
nni_mtx_lock(&sock->s_mx);
if (strcmp(opt, NNG_OPT_RECVTIMEO) == 0) {
rv = nni_copyin_ms(&ctx->c_rcvtimeo, v, sz, typ);
} else if (strcmp(opt, NNG_OPT_SENDTIMEO) == 0) {
rv = nni_copyin_ms(&ctx->c_sndtimeo, v, sz, typ);
- } else {
- rv = NNG_ENOTSUP;
+ } else if (ctx->c_ops.ctx_options != NULL) {
for (co = ctx->c_ops.ctx_options; co->co_name != NULL; co++) {
if (strcmp(opt, co->co_name) != 0) {
continue;
diff --git a/src/protocol/reqrep0/rep.c b/src/protocol/reqrep0/rep.c
index afc52629..4e20466b 100644
--- a/src/protocol/reqrep0/rep.c
+++ b/src/protocol/reqrep0/rep.c
@@ -667,19 +667,11 @@ static nni_proto_pipe_ops rep0_pipe_ops = {
.pipe_stop = rep0_pipe_stop,
};
-static nni_proto_ctx_option rep0_ctx_options[] = {
- // terminate list
- {
- .co_name = NULL,
- },
-};
-
static nni_proto_ctx_ops rep0_ctx_ops = {
- .ctx_init = rep0_ctx_init,
- .ctx_fini = rep0_ctx_fini,
- .ctx_send = rep0_ctx_send,
- .ctx_recv = rep0_ctx_recv,
- .ctx_options = rep0_ctx_options,
+ .ctx_init = rep0_ctx_init,
+ .ctx_fini = rep0_ctx_fini,
+ .ctx_send = rep0_ctx_send,
+ .ctx_recv = rep0_ctx_recv,
};
static nni_proto_sock_option rep0_sock_options[] = {