aboutsummaryrefslogtreecommitdiff
path: root/src/supplemental/http/http_client.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/supplemental/http/http_client.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/supplemental/http/http_client.c')
-rw-r--r--src/supplemental/http/http_client.c30
1 files changed, 2 insertions, 28 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);
-}