aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-08-05 07:44:23 -0700
committerGarrett D'Amore <garrett@damore.org>2017-08-05 07:44:23 -0700
commit489805ce5aa17db6173db5e7dc8998f9f5882ae9 (patch)
tree4e7f1db02c5e049441af446fc5b55d4910866320
parent23c4a6eab39c0d24ad0ff5d5ec7e9879b1788a9b (diff)
downloadnng-489805ce5aa17db6173db5e7dc8998f9f5882ae9.tar.gz
nng-489805ce5aa17db6173db5e7dc8998f9f5882ae9.tar.bz2
nng-489805ce5aa17db6173db5e7dc8998f9f5882ae9.zip
Minor improvements to reap start/stop logic.
-rw-r--r--src/core/endpt.c14
-rw-r--r--src/core/pipe.c12
2 files changed, 11 insertions, 15 deletions
diff --git a/src/core/endpt.c b/src/core/endpt.c
index 76545fcc..68efaae5 100644
--- a/src/core/endpt.c
+++ b/src/core/endpt.c
@@ -22,7 +22,6 @@ static void nni_ep_connect_start(nni_ep *);
static void nni_ep_connect_done(void *);
static void nni_ep_backoff_start(nni_ep *);
static void nni_ep_backoff_done(void *);
-static void nni_ep_reap(nni_ep *);
static void nni_ep_reaper(void *);
static nni_idhash *nni_eps;
@@ -31,8 +30,7 @@ static nni_list nni_ep_reap_list;
static nni_mtx nni_ep_reap_lk;
static nni_cv nni_ep_reap_cv;
static nni_thr nni_ep_reap_thr;
-static int nni_ep_reap_stop;
-static int nni_ep_reap_start;
+static int nni_ep_reap_run;
int
nni_ep_sys_init(void)
@@ -50,7 +48,7 @@ nni_ep_sys_init(void)
nni_idhash_set_limits(
nni_eps, 1, 0x7fffffff, nni_random() & 0x7fffffff);
- nni_ep_reap_start = 1;
+ nni_ep_reap_run = 1;
nni_thr_run(&nni_ep_reap_thr);
return (0);
@@ -59,9 +57,9 @@ nni_ep_sys_init(void)
void
nni_ep_sys_fini(void)
{
- if (nni_ep_reap_start) {
+ if (nni_ep_reap_run) {
nni_mtx_lock(&nni_ep_reap_lk);
- nni_ep_reap_stop = 1;
+ nni_ep_reap_run = 0;
nni_cv_wake(&nni_ep_reap_cv);
nni_mtx_unlock(&nni_ep_reap_lk);
nni_thr_fini(&nni_ep_reap_thr);
@@ -530,7 +528,7 @@ nni_ep_list_init(nni_list *list)
NNI_LIST_INIT(list, nni_ep, ep_node);
}
-void
+static void
nni_ep_reaper(void *notused)
{
NNI_ARG_UNUSED(notused);
@@ -547,7 +545,7 @@ nni_ep_reaper(void *notused)
continue;
}
- if (nni_ep_reap_stop) {
+ if (!nni_ep_reap_run) {
break;
}
diff --git a/src/core/pipe.c b/src/core/pipe.c
index 71434fcb..d13e703f 100644
--- a/src/core/pipe.c
+++ b/src/core/pipe.c
@@ -21,11 +21,9 @@ static nni_list nni_pipe_reap_list;
static nni_mtx nni_pipe_reap_lk;
static nni_cv nni_pipe_reap_cv;
static nni_thr nni_pipe_reap_thr;
-static int nni_pipe_reap_exit;
-static int nni_pipe_reap_start;
+static int nni_pipe_reap_run;
static void nni_pipe_reaper(void *);
-static void nni_pipe_destroy(nni_pipe *);
int
nni_pipe_sys_init(void)
@@ -49,7 +47,7 @@ nni_pipe_sys_init(void)
nni_idhash_set_limits(
nni_pipes, 1, 0x7fffffff, nni_random() & 0x7fffffff);
- nni_pipe_reap_start = 1;
+ nni_pipe_reap_run = 1;
nni_thr_run(&nni_pipe_reap_thr);
return (0);
@@ -58,9 +56,9 @@ nni_pipe_sys_init(void)
void
nni_pipe_sys_fini(void)
{
- if (nni_pipe_reap_start) {
+ if (nni_pipe_reap_run) {
nni_mtx_lock(&nni_pipe_reap_lk);
- nni_pipe_reap_exit = 1;
+ nni_pipe_reap_run = 0;
nni_cv_wake(&nni_pipe_reap_cv);
nni_mtx_unlock(&nni_pipe_reap_lk);
nni_thr_fini(&nni_pipe_reap_thr);
@@ -336,7 +334,7 @@ nni_pipe_reaper(void *notused)
nni_mtx_lock(&nni_pipe_reap_lk);
continue;
}
- if (nni_pipe_reap_exit) {
+ if (!nni_pipe_reap_run) {
break;
}
nni_cv_wait(&nni_pipe_reap_cv);