aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2021-09-06 12:01:26 -0700
committerGarrett D'Amore <garrett@damore.org>2021-09-06 12:01:26 -0700
commit468714a51bbc9fc6acf03479b8825ad25a2ffeb0 (patch)
tree4a6c7b186b29b6ec1c576530e3b6854d58c305c2 /src
parentd137bf383892c53265593d9a5ac17e64444091c9 (diff)
downloadnng-468714a51bbc9fc6acf03479b8825ad25a2ffeb0.tar.gz
nng-468714a51bbc9fc6acf03479b8825ad25a2ffeb0.tar.bz2
nng-468714a51bbc9fc6acf03479b8825ad25a2ffeb0.zip
SP initialization cannot fail.
Diffstat (limited to 'src')
-rw-r--r--src/core/dialer.c4
-rw-r--r--src/core/dialer.h4
-rw-r--r--src/core/init.c17
-rw-r--r--src/core/listener.c4
-rw-r--r--src/core/listener.h4
-rw-r--r--src/core/pipe.c6
-rw-r--r--src/core/pipe.h7
-rw-r--r--src/core/socket.c3
-rw-r--r--src/core/socket.h4
-rw-r--r--src/sp/transport.c3
-rw-r--r--src/sp/transport.h2
11 files changed, 26 insertions, 32 deletions
diff --git a/src/core/dialer.c b/src/core/dialer.c
index 4c3e563d..3a749085 100644
--- a/src/core/dialer.c
+++ b/src/core/dialer.c
@@ -23,13 +23,11 @@ static void dialer_timer_cb(void *);
static nni_id_map dialers;
static nni_mtx dialers_lk;
-int
+void
nni_dialer_sys_init(void)
{
nni_id_map_init(&dialers, 1, 0x7fffffff, false);
nni_mtx_init(&dialers_lk);
-
- return (0);
}
void
diff --git a/src/core/dialer.h b/src/core/dialer.h
index df923209..b6ba657b 100644
--- a/src/core/dialer.h
+++ b/src/core/dialer.h
@@ -1,5 +1,5 @@
//
-// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
// Copyright 2018 Devolutions <info@devolutions.net>
//
@@ -12,7 +12,7 @@
#ifndef CORE_DIALER_H
#define CORE_DIALER_H
-extern int nni_dialer_sys_init(void);
+extern void nni_dialer_sys_init(void);
extern void nni_dialer_sys_fini(void);
extern int nni_dialer_find(nni_dialer **, uint32_t);
extern int nni_dialer_hold(nni_dialer *);
diff --git a/src/core/init.c b/src/core/init.c
index 9f39490a..c923fdf0 100644
--- a/src/core/init.c
+++ b/src/core/init.c
@@ -42,16 +42,19 @@ nni_init_helper(void)
((rv = nni_reap_sys_init()) != 0) ||
((rv = nni_timer_sys_init()) != 0) ||
((rv = nni_aio_sys_init()) != 0) ||
- ((rv = nni_sock_sys_init()) != 0) ||
- ((rv = nni_listener_sys_init()) != 0) ||
- ((rv = nni_dialer_sys_init()) != 0) ||
- ((rv = nni_pipe_sys_init()) != 0) ||
- ((rv = nni_tls_sys_init()) != 0) ||
- ((rv = nni_sp_tran_sys_init()) != 0)) {
+ ((rv = nni_tls_sys_init()) != 0)) {
nni_fini();
+ return (rv);
}
- return (rv);
+ // following never fail
+ nni_sock_sys_init();
+ nni_listener_sys_init();
+ nni_dialer_sys_init();
+ nni_pipe_sys_init();
+ nni_sp_tran_sys_init();
+
+ return (0);
}
int
diff --git a/src/core/listener.c b/src/core/listener.c
index 410988f6..74e5e22b 100644
--- a/src/core/listener.c
+++ b/src/core/listener.c
@@ -24,13 +24,11 @@ static void listener_timer_cb(void *);
static nni_id_map listeners;
static nni_mtx listeners_lk;
-int
+void
nni_listener_sys_init(void)
{
nni_id_map_init(&listeners, 1, 0x7fffffff, false);
nni_mtx_init(&listeners_lk);
-
- return (0);
}
void
diff --git a/src/core/listener.h b/src/core/listener.h
index ef87a930..9b1ad907 100644
--- a/src/core/listener.h
+++ b/src/core/listener.h
@@ -1,5 +1,5 @@
//
-// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
// Copyright 2018 Devolutions <info@devolutions.net>
//
@@ -12,7 +12,7 @@
#ifndef CORE_LISTENER_H
#define CORE_LISTENER_H
-extern int nni_listener_sys_init(void);
+extern void nni_listener_sys_init(void);
extern void nni_listener_sys_fini(void);
extern int nni_listener_find(nni_listener **, uint32_t);
extern int nni_listener_hold(nni_listener *);
diff --git a/src/core/pipe.c b/src/core/pipe.c
index a2b6411f..47a78f35 100644
--- a/src/core/pipe.c
+++ b/src/core/pipe.c
@@ -1,5 +1,5 @@
//
-// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
// Copyright 2018 Devolutions <info@devolutions.net>
//
@@ -29,7 +29,7 @@ static nni_reap_list pipe_reap_list = {
.rl_func = pipe_destroy,
};
-int
+void
nni_pipe_sys_init(void)
{
nni_mtx_init(&pipes_lk);
@@ -37,8 +37,6 @@ nni_pipe_sys_init(void)
// Pipe IDs needs to have high order bit clear, and we want
// them to start at a random value.
nni_id_map_init(&pipes, 1, 0x7fffffff, true);
-
- return (0);
}
void
diff --git a/src/core/pipe.h b/src/core/pipe.h
index fe908936..065b3dcf 100644
--- a/src/core/pipe.h
+++ b/src/core/pipe.h
@@ -1,5 +1,5 @@
//
-// Copyright 2019 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
@@ -12,14 +12,14 @@
#define CORE_PIPE_H
// NB: This structure is supplied here for use by the CORE. Use of this
-// OUSIDE of the core is STRICTLY VERBOTEN. NO DIRECT ACCESS BY PROTOCOLS OR
+// OUTSIDE of the core is STRICTLY VERBOTEN. NO DIRECT ACCESS BY PROTOCOLS OR
// TRANSPORTS.
#include "core/defs.h"
#include "core/thread.h"
#include "sp/transport.h"
-extern int nni_pipe_sys_init(void);
+extern void nni_pipe_sys_init(void);
extern void nni_pipe_sys_fini(void);
// AIO
@@ -34,7 +34,6 @@ extern uint32_t nni_pipe_id(nni_pipe *);
// actual pipe will be reaped asynchronously.
extern void nni_pipe_close(nni_pipe *);
-extern uint16_t nni_pipe_proto(nni_pipe *);
extern uint16_t nni_pipe_peer(nni_pipe *);
// nni_pipe_getopt looks up the option. The last argument is the type,
diff --git a/src/core/socket.c b/src/core/socket.c
index e8b1211f..e376b773 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -608,7 +608,7 @@ nni_sock_create(nni_sock **sp, const nni_proto *proto)
return (rv);
}
-int
+void
nni_sock_sys_init(void)
{
NNI_LIST_INIT(&sock_list, nni_sock, s_node);
@@ -617,7 +617,6 @@ nni_sock_sys_init(void)
nni_id_map_init(&sock_ids, 1, 0x7fffffff, false);
nni_id_map_init(&ctx_ids, 1, 0x7fffffff, false);
inited = true;
- return (0);
}
void
diff --git a/src/core/socket.h b/src/core/socket.h
index 57a77681..59ceffa8 100644
--- a/src/core/socket.h
+++ b/src/core/socket.h
@@ -11,7 +11,7 @@
#ifndef CORE_SOCKET_H
#define CORE_SOCKET_H
-extern int nni_sock_sys_init(void);
+extern void nni_sock_sys_init(void);
extern void nni_sock_sys_fini(void);
extern int nni_sock_find(nni_sock **, uint32_t);
@@ -24,7 +24,7 @@ extern uint16_t nni_sock_proto_id(nni_sock *);
extern uint16_t nni_sock_peer_id(nni_sock *);
extern const char *nni_sock_proto_name(nni_sock *);
extern const char *nni_sock_peer_name(nni_sock *);
-extern void * nni_sock_proto_data(nni_sock *);
+extern void *nni_sock_proto_data(nni_sock *);
extern void nni_sock_add_stat(nni_sock *, nni_stat_item *);
extern struct nni_proto_pipe_ops *nni_sock_proto_pipe_ops(nni_sock *);
diff --git a/src/sp/transport.c b/src/sp/transport.c
index 13961eaa..ed27ebeb 100644
--- a/src/sp/transport.c
+++ b/src/sp/transport.c
@@ -70,7 +70,7 @@ extern void nni_sp_wss_register(void);
extern void nni_sp_zt_register(void);
#endif
-int
+void
nni_sp_tran_sys_init(void)
{
NNI_LIST_INIT(&sp_tran_list, nni_sp_tran, tran_link);
@@ -97,7 +97,6 @@ nni_sp_tran_sys_init(void)
#ifdef NNG_TRANSPORT_ZEROTIER
nni_sp_zt_register();
#endif
- return (0);
}
// nni_sp_tran_sys_fini finalizes the entire transport system, including all
diff --git a/src/sp/transport.h b/src/sp/transport.h
index 08f169bc..76d8d36a 100644
--- a/src/sp/transport.h
+++ b/src/sp/transport.h
@@ -169,7 +169,7 @@ struct nni_sp_tran {
// These APIs are used by the framework internally, and not for use by
// transport implementations.
extern nni_sp_tran *nni_sp_tran_find(nni_url *);
-extern int nni_sp_tran_sys_init(void);
+extern void nni_sp_tran_sys_init(void);
extern void nni_sp_tran_sys_fini(void);
extern void nni_sp_tran_register(nni_sp_tran *);