aboutsummaryrefslogtreecommitdiff
path: root/src/protocol/reqrep
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-01-16 16:27:22 -0800
committerGarrett D'Amore <garrett@damore.org>2017-01-16 16:27:22 -0800
commitac8415c24ffea645105c3859e814843e81c97f8a (patch)
tree7b64b4aab3de6ce5bdd69c3d5b7ead57f4a4b4e7 /src/protocol/reqrep
parentb8f7236aa2928d70d9bff2e1071654982539eeda (diff)
downloadnng-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/reqrep')
-rw-r--r--src/protocol/reqrep/rep.c16
-rw-r--r--src/protocol/reqrep/req.c20
2 files changed, 22 insertions, 14 deletions
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);
+ }
}
diff --git a/src/protocol/reqrep/req.c b/src/protocol/reqrep/req.c
index 73ef4969..787997e8 100644
--- a/src/protocol/reqrep/req.c
+++ b/src/protocol/reqrep/req.c
@@ -89,14 +89,16 @@ nni_req_sock_fini(void *arg)
{
nni_req_sock *req = arg;
- nni_cv_fini(&req->cv);
- if (req->reqmsg != NULL) {
- nni_msg_free(req->reqmsg);
- }
- if (req->retrymsg != NULL) {
- nni_msg_free(req->retrymsg);
+ if (req != NULL) {
+ nni_cv_fini(&req->cv);
+ if (req->reqmsg != NULL) {
+ nni_msg_free(req->reqmsg);
+ }
+ if (req->retrymsg != NULL) {
+ nni_msg_free(req->retrymsg);
+ }
+ NNI_FREE_STRUCT(req);
}
- NNI_FREE_STRUCT(req);
}
@@ -121,7 +123,9 @@ nni_req_pipe_fini(void *arg)
{
nni_req_pipe *rp = arg;
- NNI_FREE_STRUCT(rp);
+ if (rp != NULL) {
+ NNI_FREE_STRUCT(rp);
+ }
}