]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:smb2_sesssetup: let smbd_smb2_logoff_* use smbXsrv_session_shutdown_*
authorStefan Metzmacher <metze@samba.org>
Sat, 2 May 2015 14:20:06 +0000 (16:20 +0200)
committerKarolin Seeger <kseeger@samba.org>
Wed, 20 May 2015 14:34:29 +0000 (16:34 +0200)
Bug: https://bugzilla.samba.org/show_bug.cgi?id=11182

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(similar to commit 95057fe375348b918cb2ca58109f4c110a4a5f77)

source3/smbd/smb2_sesssetup.c

index a82d6960270be2637da585e71ed1148433f8a03f..00ef993e9f6f7ca9fe1ec1a1fde8ce4116e1f115 100644 (file)
@@ -28,7 +28,6 @@
 #include "../lib/tsocket/tsocket.h"
 #include "../libcli/security/security.h"
 #include "../lib/util/tevent_ntstatus.h"
-#include "lib/smbd_tevent_queue.h"
 
 static struct tevent_req *smbd_smb2_session_setup_send(TALLOC_CTX *mem_ctx,
                                        struct tevent_context *ev,
@@ -828,94 +827,50 @@ static void smbd_smb2_request_logoff_done(struct tevent_req *subreq)
        }
 }
 
-struct smbd_smb2_logout_state {
+struct smbd_smb2_logoff_state {
        struct smbd_smb2_request *smb2req;
-       struct tevent_queue *wait_queue;
 };
 
-static void smbd_smb2_logoff_wait_done(struct tevent_req *subreq);
+static void smbd_smb2_logoff_shutdown_done(struct tevent_req *subreq);
 
 static struct tevent_req *smbd_smb2_logoff_send(TALLOC_CTX *mem_ctx,
                                        struct tevent_context *ev,
                                        struct smbd_smb2_request *smb2req)
 {
        struct tevent_req *req;
-       struct smbd_smb2_logout_state *state;
+       struct smbd_smb2_logoff_state *state;
        struct tevent_req *subreq;
-       struct smbd_smb2_request *preq;
 
        req = tevent_req_create(mem_ctx, &state,
-                       struct smbd_smb2_logout_state);
+                       struct smbd_smb2_logoff_state);
        if (req == NULL) {
                return NULL;
        }
        state->smb2req = smb2req;
 
-       state->wait_queue = tevent_queue_create(state, "logoff_wait_queue");
-       if (tevent_req_nomem(state->wait_queue, req)) {
-               return tevent_req_post(req, ev);
-       }
-
-       /*
-        * Make sure that no new request will be able to use this session.
-        */
-       smb2req->session->status = NT_STATUS_USER_SESSION_DELETED;
-
-       for (preq = smb2req->sconn->smb2.requests; preq != NULL; preq = preq->next) {
-               if (preq == smb2req) {
-                       /* Can't cancel current request. */
-                       continue;
-               }
-               if (preq->session != smb2req->session) {
-                       /* Request on different session. */
-                       continue;
-               }
-
-               /*
-                * Never cancel anything in a compound
-                * request. Way too hard to deal with
-                * the result.
-                */
-               if (!preq->compound_related && preq->subreq != NULL) {
-                       tevent_req_cancel(preq->subreq);
-               }
-
-               /*
-                * Now wait until the request is finished.
-                *
-                * We don't set a callback, as we just want to block the
-                * wait queue and the talloc_free() of the request will
-                * remove the item from the wait queue.
-                */
-               subreq = smbd_tevent_queue_wait_send(preq, ev, state->wait_queue);
-               if (tevent_req_nomem(subreq, req)) {
-                       return tevent_req_post(req, ev);
-               }
-       }
-
-       /*
-        * Now we add our own waiter to the end of the queue,
-        * this way we get notified when all pending requests are finished
-        * and send to the socket.
-        */
-       subreq = smbd_tevent_queue_wait_send(state, ev, state->wait_queue);
+       subreq = smb2srv_session_shutdown_send(state, ev,
+                                              smb2req->session,
+                                              smb2req);
        if (tevent_req_nomem(subreq, req)) {
                return tevent_req_post(req, ev);
        }
-       tevent_req_set_callback(subreq, smbd_smb2_logoff_wait_done, req);
+       tevent_req_set_callback(subreq, smbd_smb2_logoff_shutdown_done, req);
 
        return req;
 }
 
-static void smbd_smb2_logoff_wait_done(struct tevent_req *subreq)
+static void smbd_smb2_logoff_shutdown_done(struct tevent_req *subreq)
 {
        struct tevent_req *req = tevent_req_callback_data(
                subreq, struct tevent_req);
-       struct smbd_smb2_logout_state *state = tevent_req_data(
-               req, struct smbd_smb2_logout_state);
+       struct smbd_smb2_logoff_state *state = tevent_req_data(
+               req, struct smbd_smb2_logoff_state);
        NTSTATUS status;
 
-       smbd_tevent_queue_wait_recv(subreq);
+       status = smb2srv_session_shutdown_recv(subreq);
+       if (tevent_req_nterror(req, status)) {
+               return;
+       }
        TALLOC_FREE(subreq);
 
        /*