From 24f54b976eb5835f24c03c792bceaaa723cef948 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Fri, 11 Aug 2017 08:27:40 -0700 Subject: 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. --- tests/pollfd.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/pollfd.c') 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; -- cgit v1.2.3-70-g09d2