socket_wrapper.c: let swrap_vioctl() handle SIOCOUTQ/TIOCOUTQ/FIONWRITE explicitly
authorStefan Metzmacher <metze@samba.org>
Mon, 8 Jun 2020 12:21:25 +0000 (14:21 +0200)
committerStefan Metzmacher <metze@samba.org>
Fri, 19 Jun 2020 20:59:00 +0000 (22:59 +0200)
They are used to ask for the number of unacked bytes in the send queue,
with AF_UNIX sockets get strange result, on linux 5.3 I get more bytes
reported than I sent into the socket. All bytes reach the destination
directly, so we can just always report 0 unacked bytes.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11897

Signed-off-by: Stefan Metzmacher <metze@samba.org>
src/socket_wrapper.c

index e7a7a8a02043ddb29b0fc44a21bd7d0bbbcf304f..333bdd40df72deea2b0e6e0cbadd6e5998e0a93f 100644 (file)
@@ -4660,6 +4660,24 @@ static int swrap_vioctl(int s, unsigned long int r, va_list va)
                        swrap_pcap_dump_packet(si, NULL, SWRAP_PENDING_RST, NULL, 0);
                }
                break;
+#ifdef FIONWRITE
+       case FIONWRITE:
+               /* this is FreeBSD */
+               FALL_THROUGH; /* to TIOCOUTQ */
+#endif /* FIONWRITE */
+       case TIOCOUTQ: /* same as SIOCOUTQ on Linux */
+               /*
+                * This may return more bytes then the application
+                * sent into the socket, for tcp it should
+                * return the number of unacked bytes.
+                *
+                * On AF_UNIX, all bytes are immediately acked!
+                */
+               if (rc == 0) {
+                       value_ptr = ((int *)va_arg(ap, int *));
+                       *value_ptr = 0;
+               }
+               break;
        }
 
        va_end(ap);