aboutsummaryrefslogtreecommitdiff
path: root/src/sp/transport.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2021-12-05 22:11:24 -0500
committerGarrett D'Amore <garrett@damore.org>2021-12-05 23:04:45 -0500
commitc9bbe8eb574fe10ff16cc71a23fcc9b31fb8ed04 (patch)
tree3a135bbee8750cc1b1869cfca6a2e6f24bf8e59c /src/sp/transport.c
parenteee06d1e8365ea1b1aa9363a3c6445745b002324 (diff)
downloadnng-c9bbe8eb574fe10ff16cc71a23fcc9b31fb8ed04.tar.gz
nng-c9bbe8eb574fe10ff16cc71a23fcc9b31fb8ed04.tar.bz2
nng-c9bbe8eb574fe10ff16cc71a23fcc9b31fb8ed04.zip
Use static initialization for lists and mutexes.
This eliminates some run-time initialization, moving it to compile time. Additional follow up work will expand on this to simplify initialization and reduce the need for certain locks.
Diffstat (limited to 'src/sp/transport.c')
-rw-r--r--src/sp/transport.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/sp/transport.c b/src/sp/transport.c
index ed27ebeb..9f4c6522 100644
--- a/src/sp/transport.c
+++ b/src/sp/transport.c
@@ -14,8 +14,9 @@
#include <stdio.h>
#include <string.h>
-static nni_list sp_tran_list;
-static nni_rwlock sp_tran_lk;
+static nni_list sp_tran_list =
+ NNI_LIST_INITIALIZER(sp_tran_list, nni_sp_tran, tran_link);
+static nni_rwlock sp_tran_lk = NNI_RWLOCK_INITIALIZER;
void
nni_sp_tran_register(nni_sp_tran *tran)
@@ -73,9 +74,6 @@ extern void nni_sp_zt_register(void);
void
nni_sp_tran_sys_init(void)
{
- NNI_LIST_INIT(&sp_tran_list, nni_sp_tran, tran_link);
- nni_rwlock_init(&sp_tran_lk);
-
#ifdef NNG_TRANSPORT_INPROC
nni_sp_inproc_register();
#endif
@@ -110,5 +108,4 @@ nni_sp_tran_sys_fini(void)
nni_list_remove(&sp_tran_list, t);
t->tran_fini();
}
- nni_rwlock_fini(&sp_tran_lk);
}