s3: Move the drain_socket on error to reply_write_and_X
authorVolker Lendecke <vl@samba.org>
Mon, 5 Mar 2012 14:40:49 +0000 (15:40 +0100)
committerVolker Lendecke <vl@samba.org>
Mon, 5 Mar 2012 14:59:36 +0000 (15:59 +0100)
That's the only case where this can happen, so we should not clutter the main
code path.

source3/smbd/process.c
source3/smbd/reply.c

index 15e1efe4a0a3db788719a57862f708b07f9ab421..f61ad5d24744d283cd0ae958b0a84bcfebe679bc 100644 (file)
@@ -1521,15 +1521,6 @@ static void construct_reply(struct smbd_server_connection *sconn,
 
        conn = switch_message(req->cmd, req);
 
-       if (req->unread_bytes) {
-               /* writeX failed. drain socket. */
-               if (drain_socket(req->sconn->sock, req->unread_bytes) !=
-                               req->unread_bytes) {
-                       smb_panic("failed to drain pending bytes");
-               }
-               req->unread_bytes = 0;
-       }
-
        if (req->done) {
                TALLOC_FREE(req);
                return;
index 6e6e73f58464bcc3b94ffa79548a795fbd0ba172..e3a3766239abd3dc40767bb199c5fbfdab16b9b0 100644 (file)
@@ -4647,6 +4647,15 @@ void reply_write_and_X(struct smb_request *req)
        return;
 
 out:
+       if (req->unread_bytes) {
+               /* writeX failed. drain socket. */
+               if (drain_socket(req->sconn->sock, req->unread_bytes) !=
+                               req->unread_bytes) {
+                       smb_panic("failed to drain pending bytes");
+               }
+               req->unread_bytes = 0;
+       }
+
        END_PROFILE(SMBwriteX);
        return;
 }