utils/torture.c: Added one more delete on close test.
authorJeremy Allison <jra@samba.org>
Fri, 30 Mar 2001 21:53:33 +0000 (21:53 +0000)
committerJeremy Allison <jra@samba.org>
Fri, 30 Mar 2001 21:53:33 +0000 (21:53 +0000)
smbd/notify_kernel.c: This code was wrong I believe. It was structured to only
return a changenotify event on being called from timeout processing (t != 0).
The kernel changenotify events should fire on *asynchronous* processing (EINTR
return from select caused by the realtime signal delivery) with t == 0.
Reported by Juergen Hasch (Hasch@t-online.de).
ANDREW PLEASE CHECK THIS !
Currently the hash style changenotify is done on async processing as well
as timeout processing. As this is expensive we may want to revisit doing this
and maybe set it to fire only on timeout processing.
Jeremy.
(This used to be commit f952380c5d0cfbbec1e7de98b712952f302cddfd)

source3/smbd/notify_kernel.c
source3/utils/torture.c

index 243a16a7f7a2bb093aad6604bf3fff358af43780..6509354e9b97b1a142683133f66a0bd59bf6a6e4 100644 (file)
@@ -74,14 +74,14 @@ static void signal_handler(int signal, siginfo_t *info, void *unused)
 
 /****************************************************************************
  Check if a change notify should be issued.
- time zero means instantaneous check (used for hash). Ignore this (normal method
- will be used instead).
+ time non-zero means timeout check (used for hash). Ignore this (async method
+ where time is zero will be used instead).
 *****************************************************************************/
 static BOOL kernel_check_notify(connection_struct *conn, uint16 vuid, char *path, uint32 flags, void *datap, time_t t)
 {
        struct change_data *data = (struct change_data *)datap;
 
-       if (!t)
+       if (t)
                return False;
 
        if (data->directory_handle != (int)fd_pending) return False;
index 8588aa961065706a87c7e9beac93f093064bd611..ac922eed61b5124f1a54e40dfdf8e1b1621e07ce 100644 (file)
@@ -2051,6 +2051,7 @@ static void run_oplock2(int dummy)
 static void run_deletetest(int dummy)
 {
     static struct cli_state cli1;
+    static struct cli_state cli2;
     char *fname = "\\delete.file";
     int fnum1, fnum2;
 
@@ -2324,12 +2325,66 @@ static void run_deletetest(int dummy)
 
        printf("seventh delete on close test succeeded.\n");
 
+       /* Test 7 ... */
        cli_setatr(&cli1, fname, 0, 0);
        cli_unlink(&cli1, fname);
 
+    if (!open_connection(&cli2)) {
+               printf("[8] failed to open second connection.\n");
+        return;
+    }
+
+       cli_sockopt(&cli1, sockops);
+
+       fnum1 = cli_nt_create_full(&cli1, fname, FILE_READ_DATA|FILE_WRITE_DATA|DELETE_ACCESS,
+                       FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, FILE_OVERWRITE_IF, 0);
+                                                               
+       if (fnum1 == -1) {
+               printf("[8] open of %s failed (%s)\n", fname, cli_errstr(&cli1));
+               return;
+       }
+
+       fnum2 = cli_nt_create_full(&cli2, fname, FILE_READ_DATA|FILE_WRITE_DATA|DELETE_ACCESS,
+                       FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, FILE_OPEN, 0);
+                                                               
+       if (fnum2 == -1) {
+               printf("[8] open of %s failed (%s)\n", fname, cli_errstr(&cli1));
+               return;
+       }
+
+       if (!cli_nt_delete_on_close(&cli1, fnum1, True)) {
+        printf("[8] setting delete_on_close on file failed !\n");
+        return;
+    }
+
+    if (!cli_close(&cli1, fnum1)) {
+        printf("[8] close - 1 failed (%s)\n", cli_errstr(&cli1));
+        return;
+    }
+
+    if (!cli_close(&cli2, fnum2)) {
+        printf("[8] close - 2 failed (%s)\n", cli_errstr(&cli2));
+        return;
+    }
+
+       /* This should fail.. */
+    fnum1 = cli_open(&cli1, fname, O_RDONLY, DENY_NONE);
+    if (fnum1 != -1) {
+               printf("[8] open of %s succeeded should have been deleted on close !\n", fname);
+               if (!cli_close(&cli1, fnum1)) {
+                       printf("[8] close failed (%s)\n", cli_errstr(&cli1));
+               }
+               cli_unlink(&cli1, fname);
+    } else
+               printf("eighth delete on close test succeeded.\n");
+
     printf("finished delete test\n");
 
+       cli_setatr(&cli1, fname, 0, 0);
+       cli_unlink(&cli1, fname);
+
     close_connection(&cli1);
+    close_connection(&cli2);
 }
 
 /*