print SIOCOUTQ counter before and after the writev
authorGünther Deschner <gd@samba.org>
Fri, 2 Sep 2016 15:53:06 +0000 (17:53 +0200)
committerStefan Metzmacher <metze@samba.org>
Mon, 10 Feb 2020 14:10:45 +0000 (15:10 +0100)
debug 0/10

SQ: moving SIOCOUTQ printout ...

source3/smbd/smb2_server.c

index 9400b667a496aa684083fc0fce6f271882d462b4..994ced4354c0c6e7f3fccb58164fdf2a66ee5854 100644 (file)
@@ -32,6 +32,8 @@
 #include "auth.h"
 #include "libcli/smb/smbXcli_base.h"
 #include "lib/tevent_wait.h"
+#include <sys/ioctl.h>
+#include <linux/sockios.h>
 
 #include "lib/crypto/gnutls_helpers.h"
 #include <gnutls/gnutls.h>
@@ -3781,18 +3783,26 @@ static NTSTATUS smbd_smb2_check_ack_queue(struct smbXsrv_connection *xconn)
        while (xconn->smb2.ack_queue != NULL) {
                struct smbd_smb2_send_queue *e = xconn->smb2.ack_queue;
                struct tcp_info info;
+               uint32_t value;
                socklen_t ilen = sizeof(info);
                int ret;
 
+               ret = ioctl(xconn->transport.sock, SIOCOUTQ, &value);
+               if (ret == 0) {
+                       DEBUG(10, ("%s:%s: SIOCOUTQ value is: %d\n",
+                               __location__, __func__,
+                               value));
+               }
+
                ret = getsockopt(xconn->transport.sock, IPPROTO_TCP,
                                 TCP_INFO, (void *)&info, &ilen);
                if (ret != 0) {
-                       DEBUG(0,("%s:%s: errno[%d/%s]\n",
+                       DEBUG(10,("%s:%s: errno[%d/%s]\n",
                              __location__, __func__,
                              errno, strerror(errno)));
                        ZERO_STRUCT(info);
                } else {
-                       DEBUG(0,("%s:%s: unacked[%u] sacked[%u]\n",
+                       DEBUG(10,("%s:%s: unacked[%u] sacked[%u]\n",
                              __location__, __func__,
                              (unsigned)info.tcpi_unacked,
                              (unsigned)info.tcpi_sacked));
@@ -3827,6 +3837,7 @@ static NTSTATUS smbd_smb2_flush_send_queue(struct smbXsrv_connection *xconn)
                struct smbd_smb2_send_queue *e = xconn->smb2.send_queue;
                bool ok;
                struct msghdr msg;
+               uint32_t value1, value2;
 
                if (e->sendfile_header != NULL) {
                        size_t size = 0;
@@ -3896,6 +3907,13 @@ static NTSTATUS smbd_smb2_flush_send_queue(struct smbXsrv_connection *xconn)
 
                        e->ack.started = true;
                        e->ack.seqnum = info.tcpi_sacked + iov_buflen(e->vector, e->count);
+
+                       ret = ioctl(xconn->transport.sock, SIOCOUTQ, &value1);
+                       if (ret == 0) {
+                               DEBUG(0, ("%s:%s: before write SIOCOUTQ value is: %d\n",
+                                       __location__, __func__,
+                                       value1));
+                       }
                }
 
                msg = (struct msghdr) {
@@ -3908,6 +3926,8 @@ static NTSTATUS smbd_smb2_flush_send_queue(struct smbXsrv_connection *xconn)
                        /* propagate end of file */
                        return NT_STATUS_INTERNAL_ERROR;
                }
+               DEBUG(10,("%d bytes written\n", ret));
+
                err = socket_error_from_errno(ret, errno, &retry);
                if (retry) {
                        /* retry later */
@@ -3923,6 +3943,16 @@ static NTSTATUS smbd_smb2_flush_send_queue(struct smbXsrv_connection *xconn)
                        return NT_STATUS_INTERNAL_ERROR;
                }
 
+               if (e->ack.req != NULL && e->ack.started) {
+                       int _ret;
+                       _ret = ioctl(xconn->transport.sock, SIOCOUTQ, &value2);
+                       if (_ret == 0) {
+                               DEBUG(0, ("%s:%s:  after write SIOCOUTQ value is: %d\n",
+                                       __location__, __func__,
+                                       value2));
+                       }
+               }
+
                if (e->count > 0) {
                        /* we have more to write */
                        TEVENT_FD_WRITEABLE(xconn->transport.fde);
@@ -3935,10 +3965,12 @@ static NTSTATUS smbd_smb2_flush_send_queue(struct smbXsrv_connection *xconn)
 
                xconn->smb2.send_queue_len--;
                DLIST_REMOVE(xconn->smb2.send_queue, e);
+
                if (e->ack.req != NULL && e->ack.started) {
                        DLIST_ADD_END(xconn->smb2.ack_queue, e);
                        continue;
                }
+
                talloc_free(e->mem_ctx);
        }