aboutsummaryrefslogtreecommitdiff
path: root/src/supplemental
diff options
context:
space:
mode:
Diffstat (limited to 'src/supplemental')
-rw-r--r--src/supplemental/http/http_client.c30
-rw-r--r--src/supplemental/http/http_server.c31
-rw-r--r--src/supplemental/tls/tls_common.c1
3 files changed, 5 insertions, 57 deletions
diff --git a/src/supplemental/http/http_client.c b/src/supplemental/http/http_client.c
index 3737cb7b..b156794c 100644
--- a/src/supplemental/http/http_client.c
+++ b/src/supplemental/http/http_client.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 2019 Devolutions <info@devolutions.net>
//
@@ -19,7 +19,7 @@
#include "http_api.h"
-static nni_mtx http_txn_lk;
+static nni_mtx http_txn_lk = NNI_MTX_INITIALIZER;
struct nng_http_client {
nni_list aios;
@@ -198,15 +198,6 @@ nni_http_client_connect(nni_http_client *c, nni_aio *aio)
nni_mtx_unlock(&c->mtx);
}
-static int http_client_sys_init(void);
-static void http_client_sys_fini(void);
-
-static nni_initializer http_client_initializer = {
- .i_init = http_client_sys_init,
- .i_fini = http_client_sys_fini,
- .i_once = 0,
-};
-
typedef enum http_txn_state {
HTTP_CONNECTING,
HTTP_SENDING,
@@ -385,8 +376,6 @@ nni_http_transact_conn(
http_txn *txn;
int rv;
- nni_initialize(&http_client_initializer);
-
if (nni_aio_begin(aio) != 0) {
return;
}
@@ -430,8 +419,6 @@ nni_http_transact(nni_http_client *client, nni_http_req *req,
http_txn *txn;
int rv;
- nni_initialize(&http_client_initializer);
-
if (nni_aio_begin(aio) != 0) {
return;
}
@@ -470,16 +457,3 @@ nni_http_transact(nni_http_client *client, nni_http_req *req,
nni_http_client_connect(client, txn->aio);
nni_mtx_unlock(&http_txn_lk);
}
-
-static int
-http_client_sys_init(void)
-{
- nni_mtx_init(&http_txn_lk);
- return (0);
-}
-
-static void
-http_client_sys_fini(void)
-{
- nni_mtx_fini(&http_txn_lk);
-}
diff --git a/src/supplemental/http/http_server.c b/src/supplemental/http/http_server.c
index 7f6f9abe..b7e7ac80 100644
--- a/src/supplemental/http/http_server.c
+++ b/src/supplemental/http/http_server.c
@@ -22,15 +22,6 @@
#include "http_api.h"
-static int http_server_sys_init(void);
-static void http_server_sys_fini(void);
-
-static nni_initializer http_server_initializer = {
- .i_init = http_server_sys_init,
- .i_fini = http_server_sys_fini,
- .i_once = 0,
-};
-
struct nng_http_handler {
nni_list_node node;
char * uri;
@@ -279,8 +270,9 @@ nni_http_handler_set_method(nni_http_handler *h, const char *method)
return (0);
}
-static nni_list http_servers;
-static nni_mtx http_servers_lk;
+static nni_list http_servers =
+ NNI_LIST_INITIALIZER(http_servers, nni_http_server, node);
+static nni_mtx http_servers_lk = NNI_MTX_INITIALIZER;
static void
http_sc_reap(void *arg)
@@ -1001,8 +993,6 @@ nni_http_server_init(nni_http_server **serverp, const nni_url *url)
int rv;
nni_http_server *s;
- nni_initialize(&http_server_initializer);
-
nni_mtx_lock(&http_servers_lk);
NNI_LIST_FOREACH (&http_servers, s) {
if ((!s->closed) && (atoi(url->u_port) == s->port) &&
@@ -1924,18 +1914,3 @@ nni_http_server_fini(nni_http_server *s)
}
nni_mtx_unlock(&http_servers_lk);
}
-
-static int
-http_server_sys_init(void)
-{
- NNI_LIST_INIT(&http_servers, nni_http_server, node);
- nni_mtx_init(&http_servers_lk);
- return (0);
-}
-
-static void
-http_server_sys_fini(void)
-{
- nni_reap_drain();
- nni_mtx_fini(&http_servers_lk);
-}
diff --git a/src/supplemental/tls/tls_common.c b/src/supplemental/tls/tls_common.c
index 3e497b0c..357c8411 100644
--- a/src/supplemental/tls/tls_common.c
+++ b/src/supplemental/tls/tls_common.c
@@ -1495,7 +1495,6 @@ nni_tls_sys_init(void)
void
nni_tls_sys_fini(void)
{
- nni_reap_drain();
NNG_TLS_ENGINE_FINI();
}