aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-12-29 20:13:11 -0800
committerGarrett D'Amore <garrett@damore.org>2018-12-31 14:23:34 -0800
commite0fff1f9c45f5486fc2e7eeb49b4462c3bb2dad4 (patch)
treefe6914c8b06e87880e72cb27486971bf7fc056ff /src/core
parent97118a423a48ecea816f37cb86378c5bafba2d51 (diff)
downloadnng-e0fff1f9c45f5486fc2e7eeb49b4462c3bb2dad4.tar.gz
nng-e0fff1f9c45f5486fc2e7eeb49b4462c3bb2dad4.tar.bz2
nng-e0fff1f9c45f5486fc2e7eeb49b4462c3bb2dad4.zip
fixes #835 inproc should use new option API
Some more changes to use nni_type instead of nni_opt_type are included as well.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/dialer.c6
-rw-r--r--src/core/dialer.h5
-rw-r--r--src/core/listener.c6
-rw-r--r--src/core/listener.h5
-rw-r--r--src/core/options.c38
-rw-r--r--src/core/transport.c2
6 files changed, 33 insertions, 29 deletions
diff --git a/src/core/dialer.c b/src/core/dialer.c
index 0c800333..f0589275 100644
--- a/src/core/dialer.c
+++ b/src/core/dialer.c
@@ -387,8 +387,8 @@ nni_dialer_sock(nni_dialer *d)
}
int
-nni_dialer_setopt(nni_dialer *d, const char *name, const void *val, size_t sz,
- nni_opt_type t)
+nni_dialer_setopt(
+ nni_dialer *d, const char *name, const void *val, size_t sz, nni_type t)
{
nni_option *o;
@@ -436,7 +436,7 @@ nni_dialer_setopt(nni_dialer *d, const char *name, const void *val, size_t sz,
int
nni_dialer_getopt(
- nni_dialer *d, const char *name, void *valp, size_t *szp, nni_opt_type t)
+ nni_dialer *d, const char *name, void *valp, size_t *szp, nni_type t)
{
nni_option *o;
diff --git a/src/core/dialer.h b/src/core/dialer.h
index da2cc992..af715955 100644
--- a/src/core/dialer.h
+++ b/src/core/dialer.h
@@ -1,6 +1,7 @@
//
// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
+// Copyright 2018 Devolutions <info@devolutions.net>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
@@ -23,9 +24,9 @@ extern int nni_dialer_start(nni_dialer *, int);
extern nni_sock *nni_dialer_sock(nni_dialer *);
extern int nni_dialer_setopt(
- nni_dialer *, const char *, const void *, size_t, nni_opt_type);
+ nni_dialer *, const char *, const void *, size_t, nni_type);
extern int nni_dialer_getopt(
- nni_dialer *, const char *, void *, size_t *, nni_opt_type);
+ nni_dialer *, const char *, void *, size_t *, nni_type);
extern void nni_dialer_add_stat(nni_dialer *, nni_stat_item *);
#endif // CORE_DIALER_H
diff --git a/src/core/listener.c b/src/core/listener.c
index bb46b6cb..df6dab11 100644
--- a/src/core/listener.c
+++ b/src/core/listener.c
@@ -362,8 +362,8 @@ nni_listener_sock(nni_listener *l)
}
int
-nni_listener_setopt(nni_listener *l, const char *name, const void *val,
- size_t sz, nni_opt_type t)
+nni_listener_setopt(
+ nni_listener *l, const char *name, const void *val, size_t sz, nni_type t)
{
nni_option *o;
@@ -394,7 +394,7 @@ nni_listener_setopt(nni_listener *l, const char *name, const void *val,
int
nni_listener_getopt(
- nni_listener *l, const char *name, void *valp, size_t *szp, nni_opt_type t)
+ nni_listener *l, const char *name, void *valp, size_t *szp, nni_type t)
{
nni_option *o;
diff --git a/src/core/listener.h b/src/core/listener.h
index 828102a2..12974880 100644
--- a/src/core/listener.h
+++ b/src/core/listener.h
@@ -1,6 +1,7 @@
//
// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
+// Copyright 2018 Devolutions <info@devolutions.net>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
@@ -23,9 +24,9 @@ extern int nni_listener_start(nni_listener *, int);
extern nni_sock *nni_listener_sock(nni_listener *);
extern int nni_listener_setopt(
- nni_listener *, const char *, const void *, size_t, nni_opt_type);
+ nni_listener *, const char *, const void *, size_t, nni_type);
extern int nni_listener_getopt(
- nni_listener *, const char *, void *, size_t *, nni_opt_type);
+ nni_listener *, const char *, void *, size_t *, nni_type);
extern void nni_listener_add_stat(nni_listener *, nni_stat_item *);
#endif // CORE_LISTENER_H
diff --git a/src/core/options.c b/src/core/options.c
index 23118116..0b15d6e2 100644
--- a/src/core/options.c
+++ b/src/core/options.c
@@ -15,7 +15,7 @@
#include <string.h>
int
-nni_copyin_ms(nni_duration *dp, const void *v, size_t sz, nni_opt_type t)
+nni_copyin_ms(nni_duration *dp, const void *v, size_t sz, nni_type t)
{
nni_duration dur;
@@ -43,7 +43,7 @@ nni_copyin_ms(nni_duration *dp, const void *v, size_t sz, nni_opt_type t)
}
int
-nni_copyin_bool(bool *bp, const void *v, size_t sz, nni_opt_type t)
+nni_copyin_bool(bool *bp, const void *v, size_t sz, nni_type t)
{
switch (t) {
case NNI_TYPE_BOOL:
@@ -68,7 +68,7 @@ nni_copyin_bool(bool *bp, const void *v, size_t sz, nni_opt_type t)
int
nni_copyin_int(
- int *ip, const void *v, size_t sz, int minv, int maxv, nni_opt_type t)
+ int *ip, const void *v, size_t sz, int minv, int maxv, nni_type t)
{
int i;
@@ -98,8 +98,8 @@ nni_copyin_int(
}
int
-nni_copyin_size(size_t *sp, const void *v, size_t sz, size_t minv, size_t maxv,
- nni_opt_type t)
+nni_copyin_size(
+ size_t *sp, const void *v, size_t sz, size_t minv, size_t maxv, nni_type t)
{
size_t val;
@@ -128,7 +128,7 @@ nni_copyin_size(size_t *sp, const void *v, size_t sz, size_t minv, size_t maxv,
}
int
-nni_copyin_ptr(void **pp, const void *v, size_t sz, nni_opt_type t)
+nni_copyin_ptr(void **pp, const void *v, size_t sz, nni_type t)
{
void *p;
@@ -152,7 +152,7 @@ nni_copyin_ptr(void **pp, const void *v, size_t sz, nni_opt_type t)
}
int
-nni_copyin_str(char *s, const void *v, size_t sz, size_t maxsz, nni_opt_type t)
+nni_copyin_str(char *s, const void *v, size_t sz, size_t maxsz, nni_type t)
{
size_t z;
@@ -176,7 +176,7 @@ nni_copyin_str(char *s, const void *v, size_t sz, size_t maxsz, nni_opt_type t)
}
int
-nni_copyin_u64(uint64_t *up, const void *v, size_t sz, nni_opt_type t)
+nni_copyin_u64(uint64_t *up, const void *v, size_t sz, nni_type t)
{
uint64_t u;
@@ -200,7 +200,7 @@ nni_copyin_u64(uint64_t *up, const void *v, size_t sz, nni_opt_type t)
}
int
-nni_copyin_sockaddr(nng_sockaddr *ap, const void *v, size_t sz, nni_opt_type t)
+nni_copyin_sockaddr(nng_sockaddr *ap, const void *v, size_t sz, nni_type t)
{
nng_sockaddr a;
@@ -241,7 +241,7 @@ nni_copyout(const void *src, size_t srcsz, void *dst, size_t *dstszp)
}
int
-nni_copyout_bool(bool b, void *dst, size_t *szp, nni_opt_type t)
+nni_copyout_bool(bool b, void *dst, size_t *szp, nni_type t)
{
switch (t) {
case NNI_TYPE_BOOL:
@@ -256,7 +256,7 @@ nni_copyout_bool(bool b, void *dst, size_t *szp, nni_opt_type t)
}
int
-nni_copyout_int(int i, void *dst, size_t *szp, nni_opt_type t)
+nni_copyout_int(int i, void *dst, size_t *szp, nni_type t)
{
switch (t) {
case NNI_TYPE_INT32:
@@ -271,7 +271,7 @@ nni_copyout_int(int i, void *dst, size_t *szp, nni_opt_type t)
}
int
-nni_copyout_ms(nng_duration d, void *dst, size_t *szp, nni_opt_type t)
+nni_copyout_ms(nng_duration d, void *dst, size_t *szp, nni_type t)
{
switch (t) {
case NNI_TYPE_DURATION:
@@ -286,7 +286,7 @@ nni_copyout_ms(nng_duration d, void *dst, size_t *szp, nni_opt_type t)
}
int
-nni_copyout_ptr(void *p, void *dst, size_t *szp, nni_opt_type t)
+nni_copyout_ptr(void *p, void *dst, size_t *szp, nni_type t)
{
switch (t) {
case NNI_TYPE_POINTER:
@@ -301,7 +301,7 @@ nni_copyout_ptr(void *p, void *dst, size_t *szp, nni_opt_type t)
}
int
-nni_copyout_size(size_t s, void *dst, size_t *szp, nni_opt_type t)
+nni_copyout_size(size_t s, void *dst, size_t *szp, nni_type t)
{
switch (t) {
case NNI_TYPE_SIZE:
@@ -317,7 +317,7 @@ nni_copyout_size(size_t s, void *dst, size_t *szp, nni_opt_type t)
int
nni_copyout_sockaddr(
- const nng_sockaddr *sap, void *dst, size_t *szp, nni_opt_type t)
+ const nng_sockaddr *sap, void *dst, size_t *szp, nni_type t)
{
switch (t) {
case NNI_TYPE_SOCKADDR:
@@ -332,7 +332,7 @@ nni_copyout_sockaddr(
}
int
-nni_copyout_u64(uint64_t u, void *dst, size_t *szp, nni_opt_type t)
+nni_copyout_u64(uint64_t u, void *dst, size_t *szp, nni_type t)
{
switch (t) {
case NNI_TYPE_UINT64:
@@ -347,7 +347,7 @@ nni_copyout_u64(uint64_t u, void *dst, size_t *szp, nni_opt_type t)
}
int
-nni_copyout_str(const char *str, void *dst, size_t *szp, nni_opt_type t)
+nni_copyout_str(const char *str, void *dst, size_t *szp, nni_type t)
{
char *s;
@@ -370,7 +370,7 @@ nni_copyout_str(const char *str, void *dst, size_t *szp, nni_opt_type t)
int
nni_getopt(const nni_option *opts, const char *nm, void *arg, void *buf,
- size_t *szp, nni_opt_type otype)
+ size_t *szp, nni_type otype)
{
while (opts->o_name != NULL) {
if (strcmp(opts->o_name, nm) == 0) {
@@ -386,7 +386,7 @@ nni_getopt(const nni_option *opts, const char *nm, void *arg, void *buf,
int
nni_setopt(const nni_option *opts, const char *nm, void *arg, const void *buf,
- size_t sz, nni_opt_type otype)
+ size_t sz, nni_type otype)
{
while (opts->o_name != NULL) {
if (strcmp(opts->o_name, nm) == 0) {
diff --git a/src/core/transport.c b/src/core/transport.c
index da192416..54c4bcfe 100644
--- a/src/core/transport.c
+++ b/src/core/transport.c
@@ -128,6 +128,7 @@ nni_tran_chkopt(const char *name, const void *v, size_t sz, int typ)
if ((dops->d_setopt != NULL) &&
((rv = dops->d_setopt(NULL, name, v, sz, typ)) !=
NNG_ENOTSUP)) {
+ nni_mtx_unlock(&nni_tran_lk);
return (rv);
}
for (o = dops->d_options; o && o->o_name != NULL; o++) {
@@ -146,6 +147,7 @@ nni_tran_chkopt(const char *name, const void *v, size_t sz, int typ)
if ((lops->l_setopt != NULL) &&
((rv = lops->l_setopt(NULL, name, v, sz, typ)) !=
NNG_ENOTSUP)) {
+ nni_mtx_unlock(&nni_tran_lk);
return (rv);
}
for (o = lops->l_options; o && o->o_name != NULL; o++) {