From 7bdc3db9ea5380eeee8d975b3579dcf673a0eafa Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 30 Oct 2010 16:19:33 +0200 Subject: socket_wrapper: move swrap_ioctl() above the send*/recv* functions metze --- lib/socket_wrapper/socket_wrapper.c | 52 ++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'lib') diff --git a/lib/socket_wrapper/socket_wrapper.c b/lib/socket_wrapper/socket_wrapper.c index 1fe3832a17..d1508adbca 100644 --- a/lib/socket_wrapper/socket_wrapper.c +++ b/lib/socket_wrapper/socket_wrapper.c @@ -1870,6 +1870,32 @@ _PUBLIC_ int swrap_setsockopt(int s, int level, int optname, const void *o } } +_PUBLIC_ int swrap_ioctl(int s, int r, void *p) +{ + int ret; + struct socket_info *si = find_socket_info(s); + int value; + + if (!si) { + return real_ioctl(s, r, p); + } + + ret = real_ioctl(s, r, p); + + switch (r) { + case FIONREAD: + value = *((int *)p); + if (ret == -1 && errno != EAGAIN && errno != ENOBUFS) { + swrap_dump_packet(si, NULL, SWRAP_PENDING_RST, NULL, 0); + } else if (value == 0) { /* END OF FILE */ + swrap_dump_packet(si, NULL, SWRAP_PENDING_RST, NULL, 0); + } + break; + } + + return ret; +} + _PUBLIC_ ssize_t swrap_recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen) { struct sockaddr_un un_addr; @@ -2026,32 +2052,6 @@ _PUBLIC_ ssize_t swrap_sendto(int s, const void *buf, size_t len, int flags, con return ret; } -_PUBLIC_ int swrap_ioctl(int s, int r, void *p) -{ - int ret; - struct socket_info *si = find_socket_info(s); - int value; - - if (!si) { - return real_ioctl(s, r, p); - } - - ret = real_ioctl(s, r, p); - - switch (r) { - case FIONREAD: - value = *((int *)p); - if (ret == -1 && errno != EAGAIN && errno != ENOBUFS) { - swrap_dump_packet(si, NULL, SWRAP_PENDING_RST, NULL, 0); - } else if (value == 0) { /* END OF FILE */ - swrap_dump_packet(si, NULL, SWRAP_PENDING_RST, NULL, 0); - } - break; - } - - return ret; -} - _PUBLIC_ ssize_t swrap_recv(int s, void *buf, size_t len, int flags) { int ret; -- cgit