From: Stefan Metzmacher Date: Mon, 8 Jun 2020 12:21:25 +0000 (+0200) Subject: socket_wrapper.c: let swrap_vioctl() handle SIOCOUTQ/TIOCOUTQ/FIONWRITE explicitly X-Git-Tag: socket_wrapper-1.2.5~1 X-Git-Url: http://git.samba.org/?p=socket_wrapper.git;a=commitdiff_plain;h=b94af548f42e561207db7cacbe09c9e3286de2d3 socket_wrapper.c: let swrap_vioctl() handle SIOCOUTQ/TIOCOUTQ/FIONWRITE explicitly 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 Reviewed-by: Andreas Schneider (cherry picked from commit f317ebcdcdd626ed9e06de2eb60031306994c803) --- diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index fe67285..ffdd31a 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -4751,6 +4751,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);