LATER? torture_oplock_close_handler
authorStefan Metzmacher <metze@samba.org>
Wed, 3 Sep 2014 18:41:57 +0000 (20:41 +0200)
committerGünther Deschner <gd@samba.org>
Mon, 19 Sep 2016 20:20:49 +0000 (22:20 +0200)
source4/torture/smb2/replay.c

index eaef42d3f7822e2202e352a426d9b1beafee2c20..f38aff787a2ae28f6b6685cf09e17388489f93ed 100644 (file)
@@ -104,6 +104,7 @@ struct break_info {
        struct smb2_handle handle;
        uint8_t level;
        struct smb2_break br;
+       struct smb2_close cl;
        int count;
        int failures;
        NTSTATUS failure_status;
@@ -231,6 +232,57 @@ done:
        return;
 }
 
+static void torture_oplock_close_callback(struct smb2_request *req)
+{
+       NTSTATUS status;
+
+       status = smb2_close_recv(req, &break_info.cl);
+       if (!NT_STATUS_IS_OK(status)) {
+               break_info.failures++;
+               break_info.failure_status = status;
+       }
+
+       return;
+}
+
+/* A general oplock break notification handler.  This should be used when a
+ * test expects to break from batch or exclusive to a lower level. */
+static bool torture_oplock_close_handler(struct smb2_transport *transport,
+                                        const struct smb2_handle *handle,
+                                        uint8_t level,
+                                        void *private_data)
+{
+       struct smb2_tree *tree = private_data;
+       const char *name;
+       struct smb2_request *req;
+       ZERO_STRUCT(break_info.br);
+
+       break_info.handle       = *handle;
+       break_info.level        = level;
+       break_info.count++;
+
+       switch (level) {
+       case SMB2_OPLOCK_LEVEL_II:
+               name = "level II";
+               break;
+       case SMB2_OPLOCK_LEVEL_NONE:
+               name = "none";
+               break;
+       default:
+               name = "unknown";
+               break_info.failures++;
+       }
+       printf("Got break to %s [0x%02X] => closing in oplock handler\n", name, level);
+
+       ZERO_STRUCT(break_info.cl);
+       break_info.cl.in.file.handle = *handle;
+
+       req = smb2_close_send(tree, &break_info.cl);
+       req->async.fn = torture_oplock_close_callback;
+       req->async.private_data = NULL;
+       return true;
+}
+
 /**
  * Test what happens when SMB2_FLAGS_REPLAY_OPERATION is enabled for various
  * commands. We want to verify if the server returns an error code or not.