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 15e1efe..f61ad5d 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 6e6e73f..e3a3766 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;
 }