From a003e0418774f47ceaaac5d272408244db2dfa53 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 3 Jun 2005 13:20:08 +0000 Subject: r7227: added a socket_pending() call to abstract away the FIONREAD ioctl. It will be interesting to see if this causes any portability problems, as it is a less commonly used call. --- source/lib/socket/socket_unix.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'source/lib/socket/socket_unix.c') diff --git a/source/lib/socket/socket_unix.c b/source/lib/socket/socket_unix.c index 04ba89578f8..f27076b5d8a 100644 --- a/source/lib/socket/socket_unix.c +++ b/source/lib/socket/socket_unix.c @@ -316,6 +316,16 @@ static int unixdom_get_fd(struct socket_context *sock) return sock->fd; } +static NTSTATUS unixdom_pending(struct socket_context *sock, size_t *npending) +{ + int value = 0; + if (ioctl(sock->fd, FIONREAD, &value) == 0) { + *npending = value; + return NT_STATUS_OK; + } + return map_nt_error_from_unix(errno); +} + static const struct socket_ops unixdom_ops = { .name = "unix", .fn_init = unixdom_init, @@ -327,6 +337,7 @@ static const struct socket_ops unixdom_ops = { .fn_send = unixdom_send, .fn_sendto = unixdom_sendto, .fn_close = unixdom_close, + .fn_pending = unixdom_pending, .fn_set_option = unixdom_set_option, -- cgit