TODO: smb_request_done() aio...
authorStefan Metzmacher <metze@samba.org>
Wed, 11 Jun 2014 07:43:19 +0000 (09:43 +0200)
committerStefan Metzmacher <metze@samba.org>
Mon, 10 Feb 2020 13:50:20 +0000 (14:50 +0100)
source3/smbd/aio.c

index 0f824f5aa1f69171e7fb71f8c4ec099c313e4cde..2030fa34f0a88780c2c7d07f995c5a08dec5bee8 100644 (file)
@@ -30,6 +30,7 @@
 *****************************************************************************/
 
 struct aio_extra {
+       uint64_t mid;
        files_struct *fsp;
        struct smb_request *smbreq;
        DATA_BLOB outbuf;
@@ -237,6 +238,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;
        size_t outsize;
        char *outbuf = (char *)aio_ex->outbuf.data;
@@ -257,6 +259,9 @@ static void aio_pread_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);
+
        if (nread < 0) {
                DEBUG( 3, ("handle_aio_read_complete: file %s nread == %d. "
                           "Error = %s\n", fsp_str_dbg(fsp), (int)nread,
@@ -285,12 +290,6 @@ static void aio_pread_smb1_done(struct tevent_req *req)
        _smb_setlen_large(outbuf, outsize);
 
        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",
@@ -298,6 +297,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 {
@@ -511,6 +512,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;
@@ -559,6 +561,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. */
 
@@ -585,13 +590,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",
@@ -599,6 +597,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)