Revert "TODO timeout? libcli/smb: avoid sync close requests in tstream_smbXcli_np_des...
authorStefan Metzmacher <metze@samba.org>
Mon, 18 Apr 2016 00:11:05 +0000 (02:11 +0200)
committerStefan Metzmacher <metze@samba.org>
Tue, 4 Jun 2019 10:43:20 +0000 (12:43 +0200)
This reverts commit 1fa97ac96729f8bc5e4bdcaf20e6658d7d521515.

libcli/smb/tstream_smbXcli_np.c

index 92f7a2ac558433ff620677a9bb5e06edf6a97d31..8dfc4fb2466a1ad1b1879c9a92d64c1a37c93b50 100644 (file)
@@ -76,12 +76,9 @@ struct tstream_smbXcli_np_ref {
        struct tstream_smbXcli_np *cli_nps;
 };
 
-static void tstream_smbXcli_np_close_free(struct tevent_req *subreq);
-
 static int tstream_smbXcli_np_destructor(struct tstream_smbXcli_np *cli_nps)
 {
-       struct tevent_context *ev;
-       struct tevent_req *subreq;
+       NTSTATUS status;
 
        if (cli_nps->conn_ref != NULL) {
                cli_nps->conn_ref->cli_nps = NULL;
@@ -103,6 +100,8 @@ static int tstream_smbXcli_np_destructor(struct tstream_smbXcli_np *cli_nps)
        }
 
        /*
+        * TODO: do not use a sync call with a destructor!!!
+        *
         * This only happens, if a caller does talloc_free(),
         * while the everything was still ok.
         *
@@ -114,70 +113,36 @@ static int tstream_smbXcli_np_destructor(struct tstream_smbXcli_np *cli_nps)
         * never be called.
         *
         * We use a maximun timeout of 1 second == 1000 msec.
-        *
-        * We allocate the close request under cli_nps->tcon,
-        * which means that the close will arrive on the
-        * server as long as the tcon, session and connection
-        * is still valid. At this we don't care about any failures.
         */
-
        cli_nps->timeout = MIN(cli_nps->timeout, 1000);
 
-       ev = samba_tevent_context_init(cli_nps->tcon);
-       if (ev == NULL) {
-               return 0;
-       }
-
        if (cli_nps->is_smb1) {
-               subreq = smb1cli_close_send(ev, ev, cli_nps->conn,
-                                           cli_nps->timeout,
-                                           cli_nps->pid,
-                                           cli_nps->tcon,
-                                           cli_nps->session,
-                                           cli_nps->fnum, UINT32_MAX);
+               status = smb1cli_close(cli_nps->conn,
+                                      cli_nps->timeout,
+                                      cli_nps->pid,
+                                      cli_nps->tcon,
+                                      cli_nps->session,
+                                      cli_nps->fnum, UINT32_MAX);
        } else {
-               subreq = smb2cli_close_send(ev, ev, cli_nps->conn,
-                                           cli_nps->timeout,
-                                           cli_nps->session,
-                                           cli_nps->tcon,
-                                           0, /* flags */
-                                           cli_nps->fid_persistent,
-                                           cli_nps->fid_volatile);
+               status = smb2cli_close(cli_nps->conn,
+                                      cli_nps->timeout,
+                                      cli_nps->session,
+                                      cli_nps->tcon,
+                                      0, /* flags */
+                                      cli_nps->fid_persistent,
+                                      cli_nps->fid_volatile);
        }
-       if (subreq == NULL) {
-               TALLOC_FREE(ev);
-               return 0;
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(1, ("tstream_smbXcli_np_destructor: cli_close "
+                         "failed on pipe %s. Error was %s\n",
+                         cli_nps->npipe, nt_errstr(status)));
        }
-       tevent_req_set_callback(subreq, tstream_smbXcli_np_close_free, ev);
-
-       /*
-        * Make sure we don't send any requests anymore.
-        */
-       cli_nps->conn = NULL;
-
        /*
         * We can't do much on failure
         */
        return 0;
 }
 
-static void tstream_smbXcli_np_close_free(struct tevent_req *subreq)
-{
-       struct tevent_context *ev =
-               tevent_req_callback_data(subreq,
-               struct tevent_context);
-
-       /*
-        * We don't care about the result
-        */
-       TALLOC_FREE(subreq);
-
-       /*
-        * We don't need the event context anymore.
-        */
-       TALLOC_FREE(ev);
-}
-
 static int tstream_smbXcli_np_ref_destructor(struct tstream_smbXcli_np_ref *ref)
 {
        if (ref->cli_nps == NULL) {