socket_wrapper: move swrap_ioctl() above the send*/recv* functions
authorStefan Metzmacher <metze@samba.org>
Sat, 30 Oct 2010 14:19:33 +0000 (16:19 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 3 Mar 2011 21:57:26 +0000 (22:57 +0100)
metze

lib/socket_wrapper/socket_wrapper.c

index 1fe3832a1725886458acb8a1530addd96caf5797..d1508adbca97344dd9259ba43296dabc6202553c 100644 (file)
@@ -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;