aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-08-11 17:51:41 -0700
committerGarrett D'Amore <garrett@damore.org>2017-08-11 17:51:41 -0700
commitee4572147ade37bf07f8ef2f3049e8c81df312b7 (patch)
tree8a50a209aed7048671c567cae2780c779d95770d
parent2a11fd60767335660dc506237a9302dcbc5da91e (diff)
downloadnng-ee4572147ade37bf07f8ef2f3049e8c81df312b7.tar.gz
nng-ee4572147ade37bf07f8ef2f3049e8c81df312b7.tar.bz2
nng-ee4572147ade37bf07f8ef2f3049e8c81df312b7.zip
Fix leaks found in pairv1 test suite.
-rw-r--r--src/protocol/pair/pair_v1.c10
-rw-r--r--tests/pair1.c12
2 files changed, 15 insertions, 7 deletions
diff --git a/src/protocol/pair/pair_v1.c b/src/protocol/pair/pair_v1.c
index 183c260a..1a7ad9fa 100644
--- a/src/protocol/pair/pair_v1.c
+++ b/src/protocol/pair/pair_v1.c
@@ -177,16 +177,16 @@ pair1_pipe_stop(void *arg)
pair1_pipe *p = arg;
pair1_sock *s = p->psock;
+ nni_mtx_lock(&s->mtx);
+ nni_idhash_remove(s->pipes, nni_pipe_id(p->npipe));
+ nni_list_node_remove(&p->node);
+ nni_mtx_unlock(&s->mtx);
+
nni_msgq_close(p->sendq);
nni_aio_cancel(&p->aio_send, NNG_ECANCELED);
nni_aio_cancel(&p->aio_recv, NNG_ECANCELED);
nni_aio_cancel(&p->aio_putq, NNG_ECANCELED);
nni_aio_cancel(&p->aio_getq, NNG_ECANCELED);
-
- nni_mtx_lock(&s->mtx);
- nni_idhash_remove(s->pipes, nni_pipe_id(p->npipe));
- nni_list_node_remove(&p->node);
- nni_mtx_unlock(&s->mtx);
}
static void
diff --git a/tests/pair1.c b/tests/pair1.c
index b9ef9f03..da5eaa24 100644
--- a/tests/pair1.c
+++ b/tests/pair1.c
@@ -34,6 +34,7 @@ TestMain("PAIRv1 protocol", {
nng_close(s1);
nng_close(c1);
nng_close(c2);
+ nng_usleep(10000);
nni_fini();
});
@@ -119,7 +120,7 @@ TestMain("PAIRv1 protocol", {
So(nng_setopt(s1, NNG_OPT_RCVBUF, &r, sizeof(r)) == 0);
So(nng_setopt(s1, NNG_OPT_SNDBUF, &r, sizeof(r)) == 0);
So(nng_setopt(c1, NNG_OPT_RCVBUF, &r, sizeof(r)) == 0);
- tmo = 10000;
+ tmo = 100000;
So(nng_setopt(
s1, NNG_OPT_SNDTIMEO, &tmo, sizeof(tmo)) == 0);
@@ -129,6 +130,7 @@ TestMain("PAIRv1 protocol", {
for (i = 0, rv = 0; i < 10; i++) {
So(nng_msg_alloc(&msg, 0) == 0);
if ((rv = nng_sendmsg(s1, msg, 0)) != 0) {
+ nni_msg_free(msg);
break;
}
}
@@ -146,7 +148,7 @@ TestMain("PAIRv1 protocol", {
So(nng_setopt(s1, NNG_OPT_SNDBUF, &r, sizeof(r)) == 0);
So(nng_setopt(c1, NNG_OPT_RCVBUF, &r, sizeof(r)) == 0);
- tmo = 10000;
+ tmo = 30000;
So(nng_setopt(
s1, NNG_OPT_SNDTIMEO, &tmo, sizeof(tmo)) == 0);
@@ -232,6 +234,7 @@ TestMain("PAIRv1 protocol", {
So(nng_recvmsg(s1, &msg, 0) == 0);
So(nng_msg_trim_u32(msg, &v) == 0);
So(v == 0xFEEDFACE);
+ nng_msg_free(msg);
});
Convey("Reserved bits in raw header", {
@@ -254,6 +257,7 @@ TestMain("PAIRv1 protocol", {
So(nng_recvmsg(s1, &msg, 0) == 0);
So(nng_msg_trim_u32(msg, &v) == 0);
So(v == 0xFEEDFACE);
+ nng_msg_free(msg);
});
});
@@ -288,7 +292,9 @@ TestMain("PAIRv1 protocol", {
So(nng_msg_header_trim_u32(msg, &v) ==
0);
So(v == 4);
+ nng_msg_free(msg);
});
+
Convey("Large TTL passes", {
ttl = 0xff;
So(nng_setopt(s1, NNG_OPT_MAXTTL, &ttl,
@@ -304,7 +310,9 @@ TestMain("PAIRv1 protocol", {
So(nng_msg_header_trim_u32(msg, &v) ==
0);
So(v == 0xff);
+ nng_msg_free(msg);
});
+
Convey("Max TTL fails", {
ttl = 0xff;
So(nng_setopt(s1, NNG_OPT_MAXTTL, &ttl,