sq hack avoid tevent_req_create on read
authorStefan Metzmacher <metze@samba.org>
Thu, 5 Dec 2013 14:11:55 +0000 (15:11 +0100)
committerStefan Metzmacher <metze@samba.org>
Wed, 12 Mar 2014 23:04:56 +0000 (00:04 +0100)
source3/smbd/smb2_read.c

index 693f407a4a14586d1573a740f6eaad070c97daca..dc80ec99226608d0a0ef6ecfce9c933f64160bbd 100644 (file)
@@ -173,6 +173,7 @@ struct smbd_smb2_read_state {
        uint8_t _out_hdr_buf[NBT_HDR_SIZE + SMB2_HDR_BODY + 0x10];
        DATA_BLOB out_data;
        uint32_t out_remaining;
+       NTSTATUS status;
 };
 
 static struct smbd_smb2_read_state _state;
@@ -469,15 +470,18 @@ static struct tevent_req *smbd_smb2_read_send(TALLOC_CTX *mem_ctx,
                 * request to be canceled
                 */
                //tevent_req_set_cancel_fn(req, smbd_smb2_read_cancel);
+               state->status = status;
                return state;
                //return req;
        }
 
-       //if (!NT_STATUS_EQUAL(status, NT_STATUS_RETRY)) {
+       if (!NT_STATUS_EQUAL(status, NT_STATUS_RETRY)) {
+               state->status = status;
+               return state;
        //      /* Real error in setting up aio. Fail. */
        //      tevent_req_nterror(req, status);
        //      return tevent_req_post(req, ev);
-       //}
+       }
 
        /* Fallback to synchronous. */
 
@@ -499,11 +503,13 @@ static struct tevent_req *smbd_smb2_read_send(TALLOC_CTX *mem_ctx,
                //tevent_req_done(req);
                return state;//req;//tevent_req_post(req, ev);
        } else {
-//             if (!NT_STATUS_EQUAL(status, NT_STATUS_RETRY)) {
-//                     SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock);
+               if (!NT_STATUS_EQUAL(status, NT_STATUS_RETRY)) {
+                       SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock);
+               state->status = status;
+               return state;
 //                     tevent_req_nterror(req, status);
 //                     return tevent_req_post(req, ev);
-//             }
+               }
        }
 
        /* Ok, read into memory. Allocate the out buffer. */
@@ -537,6 +543,8 @@ static struct tevent_req *smbd_smb2_read_send(TALLOC_CTX *mem_ctx,
 //             /* Success. */
 //             tevent_req_done(req);
 //     }
+               state->status = status;
+               return state;
        return state;//req;//tevent_req_post(req, ev);
 }
 
@@ -584,6 +592,11 @@ static NTSTATUS smbd_smb2_read_recv(struct tevent_req *req,
        struct smbd_smb2_read_state *state = &_state;//tevent_req_data(req,
                                             //struct smbd_smb2_read_state);
 
+       if (!NT_STATUS_IS_OK(state->status)) {
+               status = state->status;
+               ZERO_STRUCTP(state);
+               return status;
+       }
        //if (tevent_req_is_nterror(req, &status)) {
        //      tevent_req_received(req);
        //      return status;