From ac8415c24ffea645105c3859e814843e81c97f8a Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Mon, 16 Jan 2017 16:27:22 -0800 Subject: 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. --- src/protocol/reqrep/rep.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/protocol/reqrep/rep.c') diff --git a/src/protocol/reqrep/rep.c b/src/protocol/reqrep/rep.c index 90346236..6410e6db 100644 --- a/src/protocol/reqrep/rep.c +++ b/src/protocol/reqrep/rep.c @@ -72,11 +72,13 @@ nni_rep_sock_fini(void *arg) { nni_rep_sock *rep = arg; - nni_idhash_destroy(rep->pipes); - if (rep->btrace != NULL) { - nni_free(rep->btrace, rep->btrace_len); + if (rep != NULL) { + nni_idhash_destroy(rep->pipes); + if (rep->btrace != NULL) { + nni_free(rep->btrace, rep->btrace_len); + } + NNI_FREE_STRUCT(rep); } - NNI_FREE_STRUCT(rep); } @@ -106,8 +108,10 @@ nni_rep_pipe_fini(void *arg) { nni_rep_pipe *rp = arg; - nni_msgq_fini(rp->sendq); - NNI_FREE_STRUCT(rp); + if (rp != NULL) { + nni_msgq_fini(rp->sendq); + NNI_FREE_STRUCT(rp); + } } -- cgit v1.2.3-70-g09d2