]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libsmb: Use async cli_smb2_unlink in async cli_unlink
authorVolker Lendecke <vl@samba.org>
Mon, 25 May 2020 16:23:31 +0000 (18:23 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 28 May 2020 19:11:38 +0000 (19:11 +0000)
No need to call the sync wrapper in cli_unlink()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/libsmb/clifile.c

index b39a7968c57ffc1b65cc7a781591e634b2c6bfe9..a6ab8f6f8c4491b4eff16a286f320f691ff87b20 100644 (file)
@@ -1858,6 +1858,7 @@ NTSTATUS cli_hardlink(
 ****************************************************************************/
 
 static void cli_unlink_done(struct tevent_req *subreq);
+static void cli_unlink_done2(struct tevent_req *subreq);
 
 struct cli_unlink_state {
        uint16_t vwv[1];
@@ -1880,6 +1881,15 @@ struct tevent_req *cli_unlink_send(TALLOC_CTX *mem_ctx,
                return NULL;
        }
 
+       if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
+               subreq = cli_smb2_unlink_send(state, ev, cli, fname, NULL);
+               if (tevent_req_nomem(subreq, req)) {
+                       return tevent_req_post(req, ev);
+               }
+               tevent_req_set_callback(subreq, cli_unlink_done2, req);
+               return req;
+       }
+
        SSVAL(state->vwv+0, 0, mayhave_attrs);
 
        bytes = talloc_array(state, uint8_t, 1);
@@ -1922,6 +1932,12 @@ static void cli_unlink_done(struct tevent_req *subreq)
        tevent_req_done(req);
 }
 
+static void cli_unlink_done2(struct tevent_req *subreq)
+{
+       NTSTATUS status = cli_smb2_unlink_recv(subreq);
+       tevent_req_simple_finish_ntstatus(subreq, status);
+}
+
 NTSTATUS cli_unlink_recv(struct tevent_req *req)
 {
        return tevent_req_simple_recv_ntstatus(req);
@@ -1934,10 +1950,6 @@ NTSTATUS cli_unlink(struct cli_state *cli, const char *fname, uint16_t mayhave_a
        struct tevent_req *req;
        NTSTATUS status = NT_STATUS_OK;
 
-       if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
-               return cli_smb2_unlink(cli, fname, NULL);
-       }
-
        frame = talloc_stackframe();
 
        if (smbXcli_conn_has_async_calls(cli->conn)) {
@@ -1965,6 +1977,7 @@ NTSTATUS cli_unlink(struct cli_state *cli, const char *fname, uint16_t mayhave_a
        }
 
        status = cli_unlink_recv(req);
+       cli->raw_status = status; /* cli_smb2_unlink_recv doesn't set this */
 
  fail:
        TALLOC_FREE(frame);