summaryrefslogtreecommitdiff
path: root/source4/torture/raw
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-07-13 16:16:29 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:10:08 -0500
commita6a8065812038a759b5521237763764d96843fa2 (patch)
treeff023caad8b49af7416bf42c683a028b669c50b3 /source4/torture/raw
parent5af1b8e009c09161d5e987e3ca2bd508b0a3ec61 (diff)
downloadsamba-a6a8065812038a759b5521237763764d96843fa2.tar.gz
samba-a6a8065812038a759b5521237763764d96843fa2.tar.bz2
samba-a6a8065812038a759b5521237763764d96843fa2.zip
r17015: add a test that closes the tcp connection with an outstanding
notify request metze (This used to be commit d90313f715e999bb925a154b8431c77638a19a50)
Diffstat (limited to 'source4/torture/raw')
-rw-r--r--source4/torture/raw/notify.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/source4/torture/raw/notify.c b/source4/torture/raw/notify.c
index 0f33a56ce1..577f461219 100644
--- a/source4/torture/raw/notify.c
+++ b/source4/torture/raw/notify.c
@@ -706,6 +706,7 @@ static BOOL test_notify_tdis(TALLOC_CTX *mem_ctx)
status = smbcli_tdis(cli);
CHECK_STATUS(status, NT_STATUS_OK);
+ cli->tree = NULL;
status = smb_raw_changenotify_recv(req, mem_ctx, &notify);
CHECK_STATUS(status, NT_STATUS_OK);
@@ -838,6 +839,71 @@ done:
return ret;
}
+static void tcp_dis_handler(struct smbcli_transport *t, void *p)
+{
+ struct smbcli_state *cli = p;
+ smbcli_transport_dead(cli->transport);
+ cli->transport = NULL;
+ cli->tree = NULL;
+}
+/*
+ basic testing of change notifies followed by tcp disconnect
+*/
+static BOOL test_notify_tcp_dis(TALLOC_CTX *mem_ctx)
+{
+ BOOL ret = True;
+ NTSTATUS status;
+ union smb_notify notify;
+ union smb_open io;
+ int fnum;
+ struct smbcli_request *req;
+ struct smbcli_state *cli = NULL;
+
+ printf("TESTING CHANGE NOTIFY FOLLOWED BY TCP DISCONNECT\n");
+
+ if (!torture_open_connection(&cli, 0)) {
+ return False;
+ }
+
+ /*
+ get a handle on the directory
+ */
+ io.generic.level = RAW_OPEN_NTCREATEX;
+ io.ntcreatex.in.root_fid = 0;
+ io.ntcreatex.in.flags = 0;
+ io.ntcreatex.in.access_mask = SEC_FILE_ALL;
+ io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY;
+ io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+ io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_READ | NTCREATEX_SHARE_ACCESS_WRITE;
+ io.ntcreatex.in.alloc_size = 0;
+ io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
+ io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+ io.ntcreatex.in.security_flags = 0;
+ io.ntcreatex.in.fname = BASEDIR;
+
+ status = smb_raw_open(cli->tree, mem_ctx, &io);
+ CHECK_STATUS(status, NT_STATUS_OK);
+ fnum = io.ntcreatex.out.file.fnum;
+
+ /* ask for a change notify,
+ on file or directory name changes */
+ notify.nttrans.level = RAW_NOTIFY_NTTRANS;
+ notify.nttrans.in.buffer_size = 1000;
+ notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_NAME;
+ notify.nttrans.in.file.fnum = fnum;
+ notify.nttrans.in.recursive = True;
+
+ req = smb_raw_changenotify_send(cli->tree, &notify);
+
+ smbcli_transport_idle_handler(cli->transport, tcp_dis_handler, 250, cli);
+
+ status = smb_raw_changenotify_recv(req, mem_ctx, &notify);
+ CHECK_STATUS(status, NT_STATUS_NET_WRITE_FAULT);
+
+done:
+ torture_close_connection(cli);
+ return ret;
+}
/*
test setting up two change notify requests on one handle
@@ -1044,6 +1110,7 @@ BOOL torture_raw_notify(struct torture_context *torture)
ret &= test_notify_tdis(mem_ctx);
ret &= test_notify_exit(mem_ctx);
ret &= test_notify_ulogoff(mem_ctx);
+ ret &= test_notify_tcp_dis(mem_ctx);
ret &= test_notify_double(cli, mem_ctx);
ret &= test_notify_tree(cli, mem_ctx);