summaryrefslogtreecommitdiff
path: root/tests/pollfd.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-08-11 08:27:40 -0700
committerGarrett D'Amore <garrett@damore.org>2017-08-11 08:27:40 -0700
commit24f54b976eb5835f24c03c792bceaaa723cef948 (patch)
tree6c7ed21706fcece066094aeb7575b1b34a2a4ecf /tests/pollfd.c
parentd612eafe174e57bad9061af3ddf0a145fe359591 (diff)
downloadnng-24f54b976eb5835f24c03c792bceaaa723cef948.tar.gz
nng-24f54b976eb5835f24c03c792bceaaa723cef948.tar.bz2
nng-24f54b976eb5835f24c03c792bceaaa723cef948.zip
Leaking poll fds.
We never set the fd->sn_init member, causing new fds to be allocated on each request for a new pollfd, and causing old ones to leak, and worse may be even to not get notified. While here, we arrange for a bit richer testing against the various options.
Diffstat (limited to 'tests/pollfd.c')
-rw-r--r--tests/pollfd.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/pollfd.c b/tests/pollfd.c
index 09ce43cc..05ed2939 100644
--- a/tests/pollfd.c
+++ b/tests/pollfd.c
@@ -56,6 +56,14 @@ TestMain("Poll FDs",
So(nng_getopt(s1, NNG_OPT_RCVFD, &fd, &sz) == 0);
So(fd != INVALID_SOCKET);
+ Convey("And it is always the same fd", {
+ int fd2;
+ sz = sizeof(fd2);
+ So(nng_getopt(s1, NNG_OPT_RCVFD, &fd2, &sz) ==
+ 0);
+ So(fd2 == fd);
+ });
+
Convey("And they start non pollable", {
struct pollfd pfd;
pfd.fd = fd;
@@ -88,6 +96,16 @@ TestMain("Poll FDs",
So(nng_send(s1, "oops", 4, 0) == 0);
});
+ Convey("Must have a big enough size", {
+ int fd;
+ size_t sz;
+ sz = 1;
+ So(nng_getopt(s1, NNG_OPT_RCVFD, &fd, &sz) ==
+ NNG_EINVAL);
+ sz = 128;
+ So(nng_getopt(s1, NNG_OPT_RCVFD, &fd, &sz) == 0);
+ So(sz == sizeof(fd));
+ });
Convey("We cannot get a send FD for PULL", {
nng_socket s3;
int fd;