summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-06-15 15:43:19 +0200
committerVolker Lendecke <vl@samba.org>2009-06-15 17:26:56 +0200
commit3014753ebebd332710e7d5ad75c868f34f00dff6 (patch)
tree79b9402ce71caa576c2360ed54f4959e2783de21 /source4
parented5c270b750ce736155a4e02fc7d2c51fe6b8c2a (diff)
downloadsamba-3014753ebebd332710e7d5ad75c868f34f00dff6.tar.gz
samba-3014753ebebd332710e7d5ad75c868f34f00dff6.tar.bz2
samba-3014753ebebd332710e7d5ad75c868f34f00dff6.zip
Fix the posixtimedlock test
The previous version depended on the fact that smb_raw_lock_send just queued stuff. This changed with ebf5523b6e2ae0.
Diffstat (limited to 'source4')
-rw-r--r--source4/torture/raw/samba3misc.c61
1 files changed, 53 insertions, 8 deletions
diff --git a/source4/torture/raw/samba3misc.c b/source4/torture/raw/samba3misc.c
index c4c790cb0a..4ec8acc7c2 100644
--- a/source4/torture/raw/samba3misc.c
+++ b/source4/torture/raw/samba3misc.c
@@ -669,6 +669,35 @@ bool torture_samba3_caseinsensitive(struct torture_context *torture)
return ret;
}
+static void close_locked_file(struct tevent_context *ev,
+ struct tevent_timer *te,
+ struct timeval now,
+ void *private_data)
+{
+ int *pfd = (int *)private_data;
+
+ TALLOC_FREE(te);
+
+ if (*pfd != -1) {
+ close(*pfd);
+ *pfd = -1;
+ }
+}
+
+struct lock_result_state {
+ NTSTATUS status;
+ bool done;
+};
+
+static void receive_lock_result(struct smbcli_request *req)
+{
+ struct lock_result_state *state =
+ (struct lock_result_state *)req->async.private_data;
+
+ state->status = smbcli_request_simple_recv(req);
+ state->done = true;
+}
+
/*
* Check that Samba3 correctly deals with conflicting posix byte range locks
* on an underlying file
@@ -695,6 +724,9 @@ bool torture_samba3_posixtimedlock(struct torture_context *tctx)
union smb_lock io;
struct smb_lock_entry lock_entry;
struct smbcli_request *req;
+ struct lock_result_state lock_result;
+
+ struct tevent_timer *te;
if (!torture_open_connection(&cli, tctx, 0)) {
ret = false;
@@ -799,17 +831,30 @@ bool torture_samba3_posixtimedlock(struct torture_context *tctx)
goto done;
}
- /*
- * Ship the async timed request to the server
- */
- event_loop_once(req->transport->socket->event.ctx);
- msleep(500);
+ lock_result.done = false;
+ req->async.fn = receive_lock_result;
+ req->async.private_data = &lock_result;
- close(fd);
+ te = tevent_add_timer(req->transport->socket->event.ctx,
+ tctx, timeval_current_ofs(1, 0),
+ close_locked_file, &fd);
+ if (te == NULL) {
+ torture_warning(tctx, "tevent_add_timer failed\n");
+ ret = false;
+ goto done;
+ }
- status = smbcli_request_simple_recv(req);
+ while ((fd != -1) || (!lock_result.done)) {
+ if (tevent_loop_once(req->transport->socket->event.ctx)
+ == -1) {
+ torture_warning(tctx, "tevent_loop_once failed: %s\n",
+ strerror(errno));
+ ret = false;
+ goto done;
+ }
+ }
- CHECK_STATUS(status, NT_STATUS_OK);
+ CHECK_STATUS(lock_result.status, NT_STATUS_OK);
done:
if (fnum != -1) {