From d159c643a6a053bba2199da7d02ce0e57eb98b87 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 21 Nov 2005 21:13:01 +0000 Subject: r11837: Add a timeout before starting a torture test. It's really fun to watch 50 simulated logins doing stuff simultaneously. This is where the async architecture *really* pays off. Volker (This used to be commit 4cca813dff1194546e85efb9aabd36f0139e5be2) --- source4/torture/rpc/xplogin.c | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/source4/torture/rpc/xplogin.c b/source4/torture/rpc/xplogin.c index d90e1534ef..5e3a4dfd8e 100644 --- a/source4/torture/rpc/xplogin.c +++ b/source4/torture/rpc/xplogin.c @@ -1373,6 +1373,8 @@ static NTSTATUS memberships_recv(struct composite_context *creq) } struct xp_login_state { + struct timeval timeout; + const char *dc_name; const char *dc_ip; const char *wks_domain; @@ -1404,6 +1406,8 @@ struct xp_login_state { }; static void xp_login_recv_conn(struct composite_context *ctx); +static void xp_login_start(struct event_context *ev, struct timed_event *te, + struct timeval tv, void *p); static void xp_login_recv_auth2(struct composite_context *ctx); static void xp_login_recv_trusts(struct composite_context *creq); static void xp_login_recv_schannel(struct composite_context *creq); @@ -1413,6 +1417,7 @@ static void xp_login_recv_domadmins(struct composite_context *creq); static void xp_login_recv_memberships(struct composite_context *creq); static struct composite_context *xp_login_send(TALLOC_CTX *mem_ctx, + struct timeval timeout, struct event_context *event_ctx, const char *dc_name, const char *dc_ip, @@ -1423,7 +1428,7 @@ static struct composite_context *xp_login_send(TALLOC_CTX *mem_ctx, const char *user_name, const char *user_pwd) { - struct composite_context *c, *creq; + struct composite_context *c; struct xp_login_state *state; c = talloc_zero(mem_ctx, struct composite_context); @@ -1439,6 +1444,7 @@ static struct composite_context *xp_login_send(TALLOC_CTX *mem_ctx, c->private_data = state; c->event_ctx = event_ctx; + state->timeout = timeout; state->dc_name = dc_name; state->dc_ip = dc_ip; state->wks_domain = wks_domain; @@ -1474,8 +1480,10 @@ static struct composite_context *xp_login_send(TALLOC_CTX *mem_ctx, state->conn.in.fallback_to_anonymous = False; state->conn.in.workgroup = wks_domain; - creq = smb_composite_connect_send(&state->conn, state, event_ctx); - composite_continue(c, creq, xp_login_recv_conn, c); + event_add_timed(c->event_ctx, state, + timeval_current_ofs(state->timeout.tv_sec, + state->timeout.tv_usec), + xp_login_start, c); return c; failed: @@ -1483,6 +1491,19 @@ static struct composite_context *xp_login_send(TALLOC_CTX *mem_ctx, return c; } +static void xp_login_start(struct event_context *ev, struct timed_event *te, + struct timeval tv, void *p) +{ + struct composite_context *c = + talloc_get_type(p, struct composite_context); + struct xp_login_state *state = + talloc_get_type(c->private_data, struct xp_login_state); + struct composite_context *creq; + + creq = smb_composite_connect_send(&state->conn, state, c->event_ctx); + composite_continue(c, creq, xp_login_recv_conn, c); +} + static void xp_login_recv_conn(struct composite_context *creq) { struct composite_context *c = @@ -1768,12 +1789,15 @@ BOOL torture_rpc_login(void) } for (i=0; i