summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2011-02-07 16:55:16 +0100
committerVolker Lendecke <vlendec@samba.org>2011-02-28 16:40:19 +0100
commitdeb58b2e941f6d307f28f7b909f388c39fe915e8 (patch)
tree6583de982e7ddd7527c50bcdd1cf1c92c9d08d27 /source3/lib
parentcf7d331511437cc0be7d2dfa9263da5658d96740 (diff)
downloadsamba-deb58b2e941f6d307f28f7b909f388c39fe915e8.tar.gz
samba-deb58b2e941f6d307f28f7b909f388c39fe915e8.tar.bz2
samba-deb58b2e941f6d307f28f7b909f388c39fe915e8.zip
s3: Add poll_one_fd()
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/util_sock.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 1de6d17a41..3dd84fe8d7 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -1766,3 +1766,30 @@ int getaddrinfo_recv(struct tevent_req *req, struct addrinfo **res)
}
return state->ret;
}
+
+int poll_one_fd(int fd, int events, int timeout, int *revents)
+{
+ struct pollfd *fds;
+ int ret;
+ int saved_errno;
+
+ fds = TALLOC_ZERO_ARRAY(talloc_tos(), struct pollfd, 2);
+ if (fds == NULL) {
+ errno = ENOMEM;
+ return -1;
+ }
+ fds[0].fd = fd;
+ fds[0].events = events;
+
+ ret = sys_poll(fds, 1, timeout);
+
+ /*
+ * Assign whatever poll did, even in the ret<=0 case.
+ */
+ *revents = fds[0].revents;
+ saved_errno = errno;
+ TALLOC_FREE(fds);
+ errno = saved_errno;
+
+ return ret;
+}