diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-01-16 16:27:22 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-01-16 16:27:22 -0800 |
| commit | ac8415c24ffea645105c3859e814843e81c97f8a (patch) | |
| tree | 7b64b4aab3de6ce5bdd69c3d5b7ead57f4a4b4e7 /src/protocol/survey | |
| parent | b8f7236aa2928d70d9bff2e1071654982539eeda (diff) | |
| download | nng-ac8415c24ffea645105c3859e814843e81c97f8a.tar.gz nng-ac8415c24ffea645105c3859e814843e81c97f8a.tar.bz2 nng-ac8415c24ffea645105c3859e814843e81c97f8a.zip | |
Start of event framework.
This compiles correctly, but doesn't actually deliver events yet.
As part of this, I've made most of the initializables in nng
safe to tear-down if uninitialized (or set to zero e.g. via calloc).
This makes it loads easier to write the teardown on error code, since
I can deinit everything, without worrying about which things have been
initialized and which have not.
Diffstat (limited to 'src/protocol/survey')
| -rw-r--r-- | src/protocol/survey/respond.c | 16 | ||||
| -rw-r--r-- | src/protocol/survey/survey.c | 10 |
2 files changed, 17 insertions, 9 deletions
diff --git a/src/protocol/survey/respond.c b/src/protocol/survey/respond.c index 0cef5a68..3a4bf52d 100644 --- a/src/protocol/survey/respond.c +++ b/src/protocol/survey/respond.c @@ -67,11 +67,13 @@ nni_resp_sock_fini(void *arg) { nni_resp_sock *psock = arg; - nni_idhash_destroy(psock->pipes); - if (psock->btrace != NULL) { - nni_free(psock->btrace, psock->btrace_len); + if (psock != NULL) { + nni_idhash_destroy(psock->pipes); + if (psock->btrace != NULL) { + nni_free(psock->btrace, psock->btrace_len); + } + NNI_FREE_STRUCT(psock); } - NNI_FREE_STRUCT(psock); } @@ -101,8 +103,10 @@ nni_resp_pipe_fini(void *arg) { nni_resp_pipe *ppipe = arg; - nni_msgq_fini(ppipe->sendq); - NNI_FREE_STRUCT(ppipe); + if (ppipe != NULL) { + nni_msgq_fini(ppipe->sendq); + NNI_FREE_STRUCT(ppipe); + } } diff --git a/src/protocol/survey/survey.c b/src/protocol/survey/survey.c index 22baf2e8..c7ce1c16 100644 --- a/src/protocol/survey/survey.c +++ b/src/protocol/survey/survey.c @@ -82,8 +82,10 @@ nni_surv_sock_fini(void *arg) { nni_surv_sock *psock = arg; - nni_cv_fini(&psock->cv); - NNI_FREE_STRUCT(psock); + if (psock != NULL) { + nni_cv_fini(&psock->cv); + NNI_FREE_STRUCT(psock); + } } @@ -114,7 +116,9 @@ nni_surv_pipe_fini(void *arg) { nni_surv_pipe *sp = arg; - NNI_FREE_STRUCT(sp); + if (sp != NULL) { + NNI_FREE_STRUCT(sp); + } } |
