s3: Priorize the async echo responder over the client
authorVolker Lendecke <vl@samba.org>
Thu, 28 Jul 2011 12:24:40 +0000 (14:24 +0200)
committerVolker Lendecke <vlendec@samba.org>
Thu, 28 Jul 2011 16:53:38 +0000 (18:53 +0200)
Without this, an active client connection can starve the echo responder. This
leads to apparently "lost" SMBs.

Autobuild-User: Volker Lendecke <vlendec@samba.org>
Autobuild-Date: Thu Jul 28 18:53:38 CEST 2011 on sn-devel-104

source3/smbd/process.c

index 5e9392bddbb8bfcf07c97e3713ee0c45f3a22fae..9df95a8d9dd091f5f2e384c0a6851d756468db94 100644 (file)
@@ -2201,10 +2201,21 @@ static void smbd_server_connection_read_handler(
        if (from_client) {
                smbd_lock_socket(sconn);
 
-               if (lp_async_smb_echo_handler() && !fd_is_readable(fd)) {
-                       DEBUG(10,("the echo listener was faster\n"));
-                       smbd_unlock_socket(sconn);
-                       return;
+               if (lp_async_smb_echo_handler()) {
+
+                       if (fd_is_readable(sconn->smb1.echo_handler.trusted_fd)) {
+                               /*
+                                * This is the super-ugly hack to
+                                * prefer the packets forwarded by the
+                                * echo handler over the ones by the
+                                * client directly
+                                */
+                               fd = sconn->smb1.echo_handler.trusted_fd;
+                       } else if (!fd_is_readable(fd)) {
+                               DEBUG(10,("the echo listener was faster\n"));
+                               smbd_unlock_socket(sconn);
+                               return;
+                       }
                }
 
                /* TODO: make this completely nonblocking */