From 11f4803d002bf5a4bba24103d6c472ea638e196e Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 24 Aug 2005 13:15:01 +0000 Subject: r9584: Fix a race condition in Samba 3. If two files are opened simultaneously with NTCREATEX_DISP_CREATE (create if not exists, else fail) they might end up with two or more times NT_STATUS_OK as EEXIST is not correctly handled. Jeremy, please look closely at this. You can easily verify this by adding a smb_msleep(100) to the top of open_file_ntcreate and run the new samba4 torture test. It does also happen without the msleep, but not as reliably. Thanks, Volker (This used to be commit c803d4c9a588e39a90ddfe900be9b9de1a861f82) --- source4/torture/torture.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'source4/torture/torture.c') diff --git a/source4/torture/torture.c b/source4/torture/torture.c index 436c7281bd..dde3c7bd5b 100644 --- a/source4/torture/torture.c +++ b/source4/torture/torture.c @@ -76,16 +76,17 @@ failed: return NULL; } -BOOL torture_open_connection_share(struct smbcli_state **c, +BOOL torture_open_connection_share(TALLOC_CTX *mem_ctx, + struct smbcli_state **c, const char *hostname, - const char *sharename) + const char *sharename, + struct event_context *ev) { NTSTATUS status; - status = smbcli_full_connection(NULL, - c, hostname, + status = smbcli_full_connection(mem_ctx, c, hostname, sharename, NULL, - cmdline_credentials, NULL); + cmdline_credentials, ev); if (!NT_STATUS_IS_OK(status)) { printf("Failed to open connection - %s\n", nt_errstr(status)); return False; @@ -102,7 +103,7 @@ BOOL torture_open_connection(struct smbcli_state **c) const char *host = lp_parm_string(-1, "torture", "host"); const char *share = lp_parm_string(-1, "torture", "share"); - return torture_open_connection_share(c, host, share); + return torture_open_connection_share(NULL, c, host, share, NULL); } @@ -2107,9 +2108,11 @@ double torture_create_procs(BOOL (*fn)(struct smbcli_state *, int), BOOL *result while (1) { if (hostname) { - if (torture_open_connection_share(¤t_cli, + if (torture_open_connection_share(NULL, + ¤t_cli, hostname, - sharename)) { + sharename, + NULL)) { break; } } else if (torture_open_connection(¤t_cli)) { -- cgit