r24332: schedule_aio_read_and_X does not need InBuf/OutBuf
authorVolker Lendecke <vlendec@samba.org>
Sat, 11 Aug 2007 16:28:10 +0000 (16:28 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:29:30 +0000 (12:29 -0500)
(This used to be commit 9ad91bd20592850d7b6393e1ac7f0e0919d69668)

source3/smbd/aio.c
source3/smbd/reply.c

index 0ba857e2e53db4d6556783fcef3dd9a9ff2587fe..49855796b73926e9427eedb002089d9cab626810 100644 (file)
@@ -51,7 +51,7 @@ static struct aio_extra *aio_list_head;
 static struct aio_extra *create_aio_ex_read(files_struct *fsp,
                                                size_t buflen,
                                                uint16 mid,
-                                               const char *inbuf)
+                                               const uint8 *inbuf)
 {
        struct aio_extra *aio_ex = SMB_MALLOC_P(struct aio_extra);
 
@@ -203,8 +203,7 @@ void initialize_async_io_handler(void)
 *****************************************************************************/
 
 BOOL schedule_aio_read_and_X(connection_struct *conn,
-                            char *inbuf, char *outbuf,
-                            int length, int len_outbuf,
+                            struct smb_request *req,
                             files_struct *fsp, SMB_OFF_T startpos,
                             size_t smb_maxcnt)
 {
@@ -224,7 +223,7 @@ BOOL schedule_aio_read_and_X(connection_struct *conn,
 
        /* Only do this on non-chained and non-chaining reads not using the
         * write cache. */
-        if (chain_size !=0 || (CVAL(inbuf,smb_vwv0) != 0xFF)
+        if (chain_size !=0 || (CVAL(req->inbuf,smb_vwv0) != 0xFF)
            || (lp_write_cache_size(SNUM(conn)) != 0) ) {
                return False;
        }
@@ -236,18 +235,19 @@ BOOL schedule_aio_read_and_X(connection_struct *conn,
                return False;
        }
 
-       /* The following is safe from integer wrap as we've already
-          checked smb_maxcnt is 128k or less. */
-       bufsize = PTR_DIFF(smb_buf(outbuf),outbuf) + smb_maxcnt;
+       /* The following is safe from integer wrap as we've already checked
+          smb_maxcnt is 128k or less. Wct is 12 for read replies */
+
+       bufsize = smb_size + 12 * 2 + smb_maxcnt;
 
-       if ((aio_ex = create_aio_ex_read(fsp, bufsize,
-                                        SVAL(inbuf,smb_mid), inbuf)) == NULL) {
+       if (!(aio_ex = create_aio_ex_read(fsp, bufsize, req->mid,
+                                         req->inbuf))) {
                DEBUG(10,("schedule_aio_read_and_X: malloc fail.\n"));
                return False;
        }
 
-       /* Copy the SMB header already setup in outbuf. */
-       memcpy(aio_ex->outbuf, outbuf, smb_buf(outbuf) - outbuf);
+       construct_reply_common((char *)req->inbuf, aio_ex->outbuf);
+       set_message((char *)req->inbuf, aio_ex->outbuf, 12, 0, True);
        SCVAL(aio_ex->outbuf,smb_vwv0,0xFF); /* Never a chained reply. */
 
        a = &aio_ex->acb;
@@ -625,8 +625,7 @@ int process_aio_queue(void)
 }
 
 BOOL schedule_aio_read_and_X(connection_struct *conn,
-                            char *inbuf, char *outbuf,
-                            int length, int len_outbuf,
+                            struct smb_request *req,
                             files_struct *fsp, SMB_OFF_T startpos,
                             size_t smb_maxcnt)
 {
index 7b981e1c8ad90f74dc8600f062b8545207f1d84b..a62b54550e9db933a1597abadf9e5db515d659ff 100644 (file)
@@ -2960,22 +2960,21 @@ void reply_read_and_X(connection_struct *conn, struct smb_request *req)
                return;
        }
 
-       if (!reply_prep_legacy(req, &inbuf, &outbuf, &length, &bufsize)) {
-               reply_nterror(req, NT_STATUS_NO_MEMORY);
+       if (!big_readX
+           && schedule_aio_read_and_X(conn, req, fsp, startpos, smb_maxcnt)) {
                END_PROFILE(SMBreadX);
+               reply_post_legacy(req, -1);
                return;
        }
 
-       set_message(inbuf,outbuf,12,0,True);
-
-       if (!big_readX
-           && schedule_aio_read_and_X(conn, inbuf, outbuf, length, bufsize,
-                                      fsp, startpos, smb_maxcnt)) {
+       if (!reply_prep_legacy(req, &inbuf, &outbuf, &length, &bufsize)) {
+               reply_nterror(req, NT_STATUS_NO_MEMORY);
                END_PROFILE(SMBreadX);
-               reply_post_legacy(req, -1);
                return;
        }
 
+       set_message(inbuf,outbuf,12,0,True);
+
        nread = send_file_readX(conn, inbuf, outbuf, length, bufsize, fsp,
                                startpos, smb_maxcnt);
        /* Only call chain_reply if not an error. */