TODO: smb_request_done() aio...
authorStefan Metzmacher <metze@samba.org>
Wed, 11 Jun 2014 07:43:19 +0000 (09:43 +0200)
committerGünther Deschner <gd@samba.org>
Mon, 19 Sep 2016 20:20:49 +0000 (22:20 +0200)
source3/smbd/aio.c

index ff1be13824634f7978cee68ef20e501394b8e973..937cb241503c6be12118f456b327f8817f03ac93 100644 (file)
@@ -51,6 +51,7 @@ void decrement_outstanding_aio_calls(void)
 *****************************************************************************/
 
 struct aio_extra {
+       uint64_t mid;
        files_struct *fsp;
        struct smb_request *smbreq;
        DATA_BLOB outbuf;
@@ -269,6 +270,7 @@ static void aio_pread_smb1_done(struct tevent_req *req)
 {
        struct aio_extra *aio_ex = tevent_req_callback_data(
                req, struct aio_extra);
+       struct smb_request *smbreq = NULL;
        files_struct *fsp = aio_ex->fsp;
        int outsize;
        char *outbuf = (char *)aio_ex->outbuf.data;
@@ -292,6 +294,9 @@ static void aio_pread_smb1_done(struct tevent_req *req)
        /* Unlock now we're done. */
        SMB_VFS_STRICT_UNLOCK(fsp->conn, fsp, &aio_ex->lock);
 
+       smbreq = talloc_move(talloc_tos(), &aio_ex->smbreq);
+       smbreq->outbuf = (char *)talloc_move(smbreq, &aio_ex->outbuf.data);
+
        if (nread < 0) {
                DEBUG( 3, ("handle_aio_read_complete: file %s nread == %d. "
                           "Error = %s\n", fsp_str_dbg(fsp), (int)nread,
@@ -312,12 +317,6 @@ static void aio_pread_smb1_done(struct tevent_req *req)
        }
        smb_setlen(outbuf, outsize - 4);
        show_msg(outbuf);
-       if (!srv_send_smb(aio_ex->smbreq->xconn, outbuf,
-                         true, aio_ex->smbreq->seqnum+1,
-                         IS_CONN_ENCRYPTED(fsp->conn), NULL)) {
-               exit_server_cleanly("handle_aio_read_complete: srv_send_smb "
-                                   "failed.");
-       }
 
        DEBUG(10, ("handle_aio_read_complete: scheduled aio_read completed "
                   "for file %s, offset %.0f, len = %u\n",
@@ -325,6 +324,8 @@ static void aio_pread_smb1_done(struct tevent_req *req)
                   (unsigned int)nread));
 
        TALLOC_FREE(aio_ex);
+
+       smb_request_done(smbreq);
 }
 
 struct pwrite_fsync_state {
@@ -543,6 +544,7 @@ static void aio_pwrite_smb1_done(struct tevent_req *req)
 {
        struct aio_extra *aio_ex = tevent_req_callback_data(
                req, struct aio_extra);
+       struct smb_request *smbreq = NULL;
        files_struct *fsp = aio_ex->fsp;
        char *outbuf = (char *)aio_ex->outbuf.data;
        ssize_t numtowrite = aio_ex->nbyte;
@@ -594,6 +596,9 @@ static void aio_pwrite_smb1_done(struct tevent_req *req)
                return;
        }
 
+       smbreq = talloc_move(talloc_tos(), &aio_ex->smbreq);
+       smbreq->outbuf = (char *)talloc_move(smbreq, &aio_ex->outbuf.data);
+
        /* We don't need outsize or set_message here as we've already set the
           fixed size length when we set up the aio call. */
 
@@ -620,13 +625,6 @@ static void aio_pwrite_smb1_done(struct tevent_req *req)
        }
 
        show_msg(outbuf);
-       if (!srv_send_smb(aio_ex->smbreq->xconn, outbuf,
-                         true, aio_ex->smbreq->seqnum+1,
-                         IS_CONN_ENCRYPTED(fsp->conn),
-                         NULL)) {
-               exit_server_cleanly("handle_aio_write_complete: "
-                                   "srv_send_smb failed.");
-       }
 
        DEBUG(10, ("handle_aio_write_complete: scheduled aio_write completed "
                   "for file %s, offset %.0f, requested %u, written = %u\n",
@@ -634,6 +632,8 @@ static void aio_pwrite_smb1_done(struct tevent_req *req)
                   (unsigned int)numtowrite, (unsigned int)nwritten));
 
        TALLOC_FREE(aio_ex);
+
+       smb_request_done(smbreq);
 }
 
 bool cancel_smb2_aio(struct smb_request *smbreq)