mirror of
https://github.com/samba-team/samba.git
synced 2025-02-23 09:57:40 +03:00
torture3: Test the next patch: No two waiters in one do_locked()
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
e341911dda
commit
79dcabfbab
@ -16,6 +16,7 @@
|
||||
^samba3.smbtorture_s3.crypt_server # expected to give ACCESS_DENIED as SMB1 encryption isn't used
|
||||
^samba3.smbtorture_s3.*.LOCK12.*\(fileserver\)
|
||||
^samba3.smbtorture_s3.*.LOCK12.*\(nt4_dc\)
|
||||
^samba3.smbtorture_s3.LOCAL-DBWRAP-WATCH4
|
||||
^samba3.nbt.dgram.*netlogon2\(nt4_dc\)
|
||||
^samba3.*rap.sam.*.useradd # Not provided by Samba 3
|
||||
^samba3.*rap.sam.*.userdelete # Not provided by Samba 3
|
||||
|
@ -214,6 +214,7 @@ local_tests = [
|
||||
"LOCAL-DBWRAP-WATCH1",
|
||||
"LOCAL-DBWRAP-WATCH2",
|
||||
"LOCAL-DBWRAP-WATCH3",
|
||||
"LOCAL-DBWRAP-WATCH4",
|
||||
"LOCAL-DBWRAP-DO-LOCKED1",
|
||||
"LOCAL-G-LOCK1",
|
||||
"LOCAL-G-LOCK2",
|
||||
|
@ -114,6 +114,7 @@ bool run_notify_bench3(int dummy);
|
||||
bool run_dbwrap_watch1(int dummy);
|
||||
bool run_dbwrap_watch2(int dummy);
|
||||
bool run_dbwrap_watch3(int dummy);
|
||||
bool run_dbwrap_watch4(int dummy);
|
||||
bool run_dbwrap_do_locked1(int dummy);
|
||||
bool run_idmap_tdb_common_test(int dummy);
|
||||
bool run_local_dbwrap_ctdb(int dummy);
|
||||
|
@ -297,3 +297,170 @@ fail:
|
||||
TALLOC_FREE(ev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Test that we can't add two watchers in the same
|
||||
* fetch_lock/do_locked round
|
||||
*/
|
||||
|
||||
struct dbwrap_watch4_state {
|
||||
TALLOC_CTX *mem_ctx;
|
||||
struct tevent_context *ev;
|
||||
struct db_context *db;
|
||||
TDB_DATA key;
|
||||
|
||||
NTSTATUS status;
|
||||
|
||||
struct tevent_req *req1;
|
||||
NTSTATUS status1;
|
||||
|
||||
struct tevent_req *req2;
|
||||
NTSTATUS status2;
|
||||
};
|
||||
|
||||
static void dbwrap_watch4_done1(struct tevent_req *subreq);
|
||||
static void dbwrap_watch4_done2(struct tevent_req *subreq);
|
||||
|
||||
static void dbwrap_watch4_fn(struct db_record *rec,
|
||||
TDB_DATA value,
|
||||
void *private_data)
|
||||
{
|
||||
struct dbwrap_watch4_state *state = private_data;
|
||||
bool ok;
|
||||
|
||||
state->req1 = dbwrap_watched_watch_send(
|
||||
state->mem_ctx, state->ev, rec, (struct server_id) { .pid=0 });
|
||||
if (state->req1 == NULL) {
|
||||
goto nomem;
|
||||
}
|
||||
tevent_req_set_callback(state->req1, dbwrap_watch4_done1, state);
|
||||
state->status1 = NT_STATUS_EVENT_PENDING;
|
||||
|
||||
ok = tevent_req_set_endtime(
|
||||
state->req1, state->ev, timeval_current_ofs(1, 0));
|
||||
if (!ok) {
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
state->req2 = dbwrap_watched_watch_send(
|
||||
state->mem_ctx, state->ev, rec, (struct server_id) { .pid=0 });
|
||||
if (state->req2 == NULL) {
|
||||
goto nomem;
|
||||
}
|
||||
tevent_req_set_callback(state->req2, dbwrap_watch4_done2, state);
|
||||
state->status2 = NT_STATUS_EVENT_PENDING;
|
||||
|
||||
ok = tevent_req_set_endtime(
|
||||
state->req2, state->ev, timeval_current_ofs(1, 0));
|
||||
if (!ok) {
|
||||
goto nomem;
|
||||
}
|
||||
|
||||
state->status = NT_STATUS_OK;
|
||||
return;
|
||||
|
||||
nomem:
|
||||
state->status = NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
static void dbwrap_watch4_done1(struct tevent_req *subreq)
|
||||
{
|
||||
struct dbwrap_watch4_state *state = tevent_req_callback_data_void(subreq);
|
||||
state->status1 = dbwrap_watched_watch_recv(subreq, NULL, NULL);
|
||||
TALLOC_FREE(subreq);
|
||||
printf("req1 finished: %s\n", nt_errstr(state->status1));
|
||||
state->req1 = NULL;
|
||||
}
|
||||
|
||||
static void dbwrap_watch4_done2(struct tevent_req *subreq)
|
||||
{
|
||||
struct dbwrap_watch4_state *state = tevent_req_callback_data_void(subreq);
|
||||
state->status2 = dbwrap_watched_watch_recv(subreq, NULL, NULL);
|
||||
TALLOC_FREE(subreq);
|
||||
printf("req2 finished: %s\n", nt_errstr(state->status2));
|
||||
state->req2 = NULL;
|
||||
}
|
||||
|
||||
bool run_dbwrap_watch4(int dummy)
|
||||
{
|
||||
struct tevent_context *ev = NULL;
|
||||
struct messaging_context *msg = NULL;
|
||||
struct db_context *backend = NULL;
|
||||
struct db_context *db = NULL;
|
||||
const char *keystr = "key";
|
||||
TDB_DATA key = string_term_tdb_data(keystr);
|
||||
struct dbwrap_watch4_state state = { 0 };
|
||||
NTSTATUS status;
|
||||
bool ret = false;
|
||||
bool ok;
|
||||
|
||||
ok = test_dbwrap_watch_init(
|
||||
talloc_tos(), "test_watch.tdb", &ev, &msg, &backend, &db);
|
||||
if (!ok) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
state = (struct dbwrap_watch4_state) {
|
||||
.mem_ctx = talloc_tos(),
|
||||
.ev = ev,
|
||||
.db = db,
|
||||
.key = key,
|
||||
};
|
||||
|
||||
status = dbwrap_do_locked(db, key, dbwrap_watch4_fn, &state);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
fprintf(stderr,
|
||||
"dbwrap_do_locked failed: %s\n",
|
||||
nt_errstr(status));
|
||||
goto fail;
|
||||
}
|
||||
if (!NT_STATUS_IS_OK(state.status)) {
|
||||
fprintf(stderr,
|
||||
"dbwrap_watch4_fn failed: %s\n",
|
||||
nt_errstr(status));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
status = dbwrap_store(db, key, key, 0);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
fprintf(stderr,
|
||||
"dbwrap_store failed: %s\n",
|
||||
nt_errstr(status));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
while (NT_STATUS_EQUAL(state.status1, NT_STATUS_EVENT_PENDING) ||
|
||||
NT_STATUS_EQUAL(state.status2, NT_STATUS_EVENT_PENDING)) {
|
||||
int res = tevent_loop_once(ev);
|
||||
if (res != 0) {
|
||||
fprintf(stderr,
|
||||
"tevent_loop_once failed: %s\n",
|
||||
strerror(errno));
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (!NT_STATUS_IS_OK(state.status1)) {
|
||||
fprintf(stderr,
|
||||
"req1 returned %s\n",
|
||||
nt_errstr(state.status1));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!NT_STATUS_EQUAL(state.status2, NT_STATUS_REQUEST_NOT_ACCEPTED)) {
|
||||
fprintf(stderr,
|
||||
"req2 returned %s\n",
|
||||
nt_errstr(state.status2));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
(void)unlink("test_watch.tdb");
|
||||
ret = true;
|
||||
fail:
|
||||
TALLOC_FREE(state.req2);
|
||||
TALLOC_FREE(state.req1);
|
||||
TALLOC_FREE(db);
|
||||
TALLOC_FREE(msg);
|
||||
TALLOC_FREE(ev);
|
||||
return ret;
|
||||
}
|
||||
|
@ -14667,6 +14667,10 @@ static struct {
|
||||
.name = "LOCAL-DBWRAP-WATCH3",
|
||||
.fn = run_dbwrap_watch3,
|
||||
},
|
||||
{
|
||||
.name = "LOCAL-DBWRAP-WATCH4",
|
||||
.fn = run_dbwrap_watch4,
|
||||
},
|
||||
{
|
||||
.name = "LOCAL-DBWRAP-DO-LOCKED1",
|
||||
.fn = run_dbwrap_do_locked1,
|
||||
|
Loading…
x
Reference in New Issue
Block a user