summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorSachin Prabhu <sprabhu@redhat.com>2019-03-14 18:15:27 +0000
committerJeremy Allison <jra@samba.org>2019-04-19 17:27:12 +0000
commitaa28477bbec4dd29826b33fce35429724d48acd3 (patch)
treeb5942c61b5fa9fddc18d6f3826e861a4e8a88431 /source4
parent7a73c56907f5f56d989a37703865c15422cce233 (diff)
downloadsamba-aa28477bbec4dd29826b33fce35429724d48acd3.tar.gz
s4-torture: move torture_wait_for_oplock_break() to central oplock handler.
Signed-off-by: Guenther Deschner <gd@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source4')
-rw-r--r--source4/torture/smb2/oplock.c54
-rw-r--r--source4/torture/smb2/oplock_break_handler.c53
-rw-r--r--source4/torture/smb2/oplock_break_handler.h1
-rw-r--r--source4/torture/smb2/replay.c55
4 files changed, 54 insertions, 109 deletions
diff --git a/source4/torture/smb2/oplock.c b/source4/torture/smb2/oplock.c
index d6156eb4d8c..885bf1a9e3a 100644
--- a/source4/torture/smb2/oplock.c
+++ b/source4/torture/smb2/oplock.c
@@ -304,60 +304,6 @@ static bool open_smb2_connection_no_level2_oplocks(struct torture_context *tctx,
return true;
}
-/*
- Timer handler function notifies the registering function that time is up
-*/
-static void timeout_cb(struct tevent_context *ev,
- struct tevent_timer *te,
- struct timeval current_time,
- void *private_data)
-{
- bool *timesup = (bool *)private_data;
- *timesup = true;
- return;
-}
-
-/*
- Wait a short period of time to receive a single oplock break request
-*/
-static void torture_wait_for_oplock_break(struct torture_context *tctx)
-{
- TALLOC_CTX *tmp_ctx = talloc_new(NULL);
- struct tevent_timer *te = NULL;
- struct timeval ne;
- bool timesup = false;
- int old_count = break_info.count;
-
- /* Wait .1 seconds for an oplock break */
- ne = tevent_timeval_current_ofs(0, 100000);
-
- if ((te = tevent_add_timer(tctx->ev, tmp_ctx, ne, timeout_cb, &timesup))
- == NULL)
- {
- torture_comment(tctx, "Failed to wait for an oplock break. "
- "test results may not be accurate.");
- goto done;
- }
-
- while (!timesup && break_info.count < old_count + 1) {
- if (tevent_loop_once(tctx->ev) != 0) {
- torture_comment(tctx, "Failed to wait for an oplock "
- "break. test results may not be "
- "accurate.");
- goto done;
- }
- }
-
-done:
- /* We don't know if the timed event fired and was freed, we received
- * our oplock break, or some other event triggered the loop. Thus,
- * we create a tmp_ctx to be able to safely free/remove the timed
- * event in all 3 cases. */
- talloc_free(tmp_ctx);
-
- return;
-}
-
static bool test_smb2_oplock_exclusive1(struct torture_context *tctx,
struct smb2_tree *tree1,
struct smb2_tree *tree2)
diff --git a/source4/torture/smb2/oplock_break_handler.c b/source4/torture/smb2/oplock_break_handler.c
index 30863a9167e..1b207810658 100644
--- a/source4/torture/smb2/oplock_break_handler.c
+++ b/source4/torture/smb2/oplock_break_handler.c
@@ -27,6 +27,7 @@
#include "torture/smb2/proto.h"
#include "../libcli/smb/smbXcli_base.h"
#include "oplock_break_handler.h"
+#include "lib/events/events.h"
struct break_info break_info;
@@ -89,3 +90,55 @@ bool torture_oplock_ack_handler(struct smb2_transport *transport,
return true;
}
+
+
+/*
+ * Timer handler function notifies the registering function that time is up
+ */
+static void timeout_cb(struct tevent_context *ev,
+ struct tevent_timer *te,
+ struct timeval current_time,
+ void *private_data)
+{
+ bool *timesup = (bool *)private_data;
+ *timesup = true;
+}
+
+/*
+ * Wait a short period of time to receive a single oplock break request
+ */
+void torture_wait_for_oplock_break(struct torture_context *tctx)
+{
+ TALLOC_CTX *tmp_ctx = talloc_new(NULL);
+ struct tevent_timer *te = NULL;
+ struct timeval ne;
+ bool timesup = false;
+ int old_count = break_info.count;
+
+ /* Wait .1 seconds for an oplock break */
+ ne = tevent_timeval_current_ofs(0, 100000);
+
+ te = tevent_add_timer(tctx->ev, tmp_ctx, ne, timeout_cb, &timesup);
+ if (te == NULL) {
+ torture_comment(tctx, "Failed to wait for an oplock break. "
+ "test results may not be accurate.");
+ goto done;
+ }
+
+ while (!timesup && break_info.count < old_count + 1) {
+ if (tevent_loop_once(tctx->ev) != 0) {
+ torture_comment(tctx, "Failed to wait for an oplock "
+ "break. test results may not be "
+ "accurate.");
+ goto done;
+ }
+ }
+
+done:
+ /* We don't know if the timed event fired and was freed, we received
+ * our oplock break, or some other event triggered the loop. Thus,
+ * we create a tmp_ctx to be able to safely free/remove the timed
+ * event in all 3 cases.
+ */
+ talloc_free(tmp_ctx);
+}
diff --git a/source4/torture/smb2/oplock_break_handler.h b/source4/torture/smb2/oplock_break_handler.h
index 78bba103fb2..6b1eeb14b63 100644
--- a/source4/torture/smb2/oplock_break_handler.h
+++ b/source4/torture/smb2/oplock_break_handler.h
@@ -40,6 +40,7 @@ bool torture_oplock_ack_handler(struct smb2_transport *transport,
const struct smb2_handle *handle,
uint8_t level,
void *private_data);
+void torture_wait_for_oplock_break(struct torture_context *tctx);
static inline void torture_reset_break_info(struct torture_context *tctx,
struct break_info *r)
diff --git a/source4/torture/smb2/replay.c b/source4/torture/smb2/replay.c
index 903adc6798f..abb026419c7 100644
--- a/source4/torture/smb2/replay.c
+++ b/source4/torture/smb2/replay.c
@@ -95,61 +95,6 @@
#define BASEDIR "replaytestdir"
/**
- * Timer handler function notifies the registering function that time is up
- */
-static void timeout_cb(struct tevent_context *ev,
- struct tevent_timer *te,
- struct timeval current_time,
- void *private_data)
-{
- bool *timesup = (bool *)private_data;
- *timesup = true;
- return;
-}
-
-/**
- * Wait a short period of time to receive a single oplock break request
- */
-static void torture_wait_for_oplock_break(struct torture_context *tctx)
-{
- TALLOC_CTX *tmp_ctx = talloc_new(NULL);
- struct tevent_timer *te = NULL;
- struct timeval ne;
- bool timesup = false;
- int old_count = break_info.count;
-
- /* Wait .1 seconds for an oplock break */
- ne = tevent_timeval_current_ofs(0, 100000);
-
- te = tevent_add_timer(tctx->ev, tmp_ctx, ne, timeout_cb, &timesup);
- if (te == NULL) {
- torture_comment(tctx, "Failed to wait for an oplock break. "
- "test results may not be accurate.");
- goto done;
- }
-
- while (!timesup && break_info.count < old_count + 1) {
- if (tevent_loop_once(tctx->ev) != 0) {
- torture_comment(tctx, "Failed to wait for an oplock "
- "break. test results may not be "
- "accurate.");
- goto done;
- }
- }
-
-done:
- /*
- * We don't know if the timed event fired and was freed, we received
- * our oplock break, or some other event triggered the loop. Thus,
- * we create a tmp_ctx to be able to safely free/remove the timed
- * event in all 3 cases.
- */
- talloc_free(tmp_ctx);
-
- return;
-}
-
-/**
* 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.
*/