diff options
| author | Michael Albinus | 2015-11-19 09:58:08 +0000 |
|---|---|---|
| committer | Michael Albinus | 2015-11-25 15:07:12 +0100 |
| commit | c8e266ff5f1862567a9f4b77b2d90b8586b12539 (patch) | |
| tree | fd41673a09a4187aa258990f65ef208c3f0d8a82 | |
| parent | 5044bdfed7a0bcf091583816ab8a95621138e7fe (diff) | |
| download | emacs-c8e266ff5f1862567a9f4b77b2d90b8586b12539.tar.gz emacs-c8e266ff5f1862567a9f4b77b2d90b8586b12539.zip | |
Handle more complex rename operation in kqueue
* src/kqueue.c (pending_events): New variable.
(kqueue_compare_dir_list): Handle more complex rename operation.
(globals_of_kqueue): Initialize pending_events.
* test/automated/file-notify-tests.el (file-notify-test06-many-events):
Adapt expected events in the `rename-file' case.
(file-notify-test06-many-events-remote): Declare.
| -rw-r--r-- | src/kqueue.c | 25 | ||||
| -rw-r--r-- | test/automated/file-notify-tests.el | 10 |
2 files changed, 23 insertions, 12 deletions
diff --git a/src/kqueue.c b/src/kqueue.c index e2c9dabcb20..fa541764169 100644 --- a/src/kqueue.c +++ b/src/kqueue.c | |||
| @@ -35,6 +35,10 @@ static int kqueuefd = -1; | |||
| 35 | /* This is a list, elements are (DESCRIPTOR FILE FLAGS CALLBACK [DIRLIST]). */ | 35 | /* This is a list, elements are (DESCRIPTOR FILE FLAGS CALLBACK [DIRLIST]). */ |
| 36 | static Lisp_Object watch_list; | 36 | static Lisp_Object watch_list; |
| 37 | 37 | ||
| 38 | /* Pending events, being the target of a rename operation. | ||
| 39 | Items are (INODE FILE-NAME LAST-MOD LAST-STATUS-MOD SIZE). */ | ||
| 40 | static Lisp_Object pending_events; | ||
| 41 | |||
| 38 | /* Generate a list from the directory_files_internal output. | 42 | /* Generate a list from the directory_files_internal output. |
| 39 | Items are (INODE FILE-NAME LAST-MOD LAST-STATUS-MOD SIZE). */ | 43 | Items are (INODE FILE-NAME LAST-MOD LAST-STATUS-MOD SIZE). */ |
| 40 | Lisp_Object | 44 | Lisp_Object |
| @@ -136,7 +140,7 @@ kqueue_compare_dir_list | |||
| 136 | 140 | ||
| 137 | /* Search for an entry with the same inode. */ | 141 | /* Search for an entry with the same inode. */ |
| 138 | old_entry = XCAR (dl); | 142 | old_entry = XCAR (dl); |
| 139 | new_entry = Fassoc (XCAR (old_entry), new_dl); | 143 | new_entry = assq_no_quit (XCAR (old_entry), new_dl); |
| 140 | if (! NILP (Fequal (old_entry, new_entry))) { | 144 | if (! NILP (Fequal (old_entry, new_entry))) { |
| 141 | /* Both entries are identical. Nothing to do. */ | 145 | /* Both entries are identical. Nothing to do. */ |
| 142 | new_dl = Fdelq (new_entry, new_dl); | 146 | new_dl = Fdelq (new_entry, new_dl); |
| @@ -177,16 +181,24 @@ kqueue_compare_dir_list | |||
| 177 | new_entry = XCAR (dl1); | 181 | new_entry = XCAR (dl1); |
| 178 | if (strcmp (SSDATA (XCAR (XCDR (old_entry))), | 182 | if (strcmp (SSDATA (XCAR (XCDR (old_entry))), |
| 179 | SSDATA (XCAR (XCDR (new_entry)))) == 0) { | 183 | SSDATA (XCAR (XCDR (new_entry)))) == 0) { |
| 180 | kqueue_generate_event | 184 | pending_events = Fcons (new_entry, pending_events); |
| 181 | (watch_object, Fcons (Qwrite, Qnil), XCAR (XCDR (old_entry)), Qnil); | ||
| 182 | new_dl = Fdelq (new_entry, new_dl); | 185 | new_dl = Fdelq (new_entry, new_dl); |
| 183 | goto the_end; | 186 | goto the_end; |
| 184 | } | 187 | } |
| 185 | } | 188 | } |
| 186 | 189 | ||
| 187 | /* The file has been deleted. */ | 190 | new_entry = assq_no_quit (XCAR (old_entry), pending_events); |
| 188 | kqueue_generate_event | 191 | if (NILP (new_entry)) |
| 189 | (watch_object, Fcons (Qdelete, Qnil), XCAR (XCDR (old_entry)), Qnil); | 192 | /* The file has been deleted. */ |
| 193 | kqueue_generate_event | ||
| 194 | (watch_object, Fcons (Qdelete, Qnil), XCAR (XCDR (old_entry)), Qnil); | ||
| 195 | else { | ||
| 196 | /* The file has been renamed. */ | ||
| 197 | kqueue_generate_event | ||
| 198 | (watch_object, Fcons (Qrename, Qnil), | ||
| 199 | XCAR (XCDR (old_entry)), XCAR (XCDR (new_entry))); | ||
| 200 | new_dl = Fdelq (new_entry, new_dl); | ||
| 201 | } | ||
| 190 | 202 | ||
| 191 | the_end: | 203 | the_end: |
| 192 | dl = XCDR (dl); | 204 | dl = XCDR (dl); |
| @@ -444,6 +456,7 @@ void | |||
| 444 | globals_of_kqueue (void) | 456 | globals_of_kqueue (void) |
| 445 | { | 457 | { |
| 446 | watch_list = Qnil; | 458 | watch_list = Qnil; |
| 459 | pending_events = Qnil; | ||
| 447 | } | 460 | } |
| 448 | 461 | ||
| 449 | void | 462 | void |
diff --git a/test/automated/file-notify-tests.el b/test/automated/file-notify-tests.el index f0068c547a5..b9cd192dd19 100644 --- a/test/automated/file-notify-tests.el +++ b/test/automated/file-notify-tests.el | |||
| @@ -661,12 +661,7 @@ Don't wait longer than timeout seconds for the events to be delivered." | |||
| 661 | (write-region "" nil file nil 'no-message)) | 661 | (write-region "" nil file nil 'no-message)) |
| 662 | (dolist (file y-file-list) | 662 | (dolist (file y-file-list) |
| 663 | (write-region "" nil file nil 'no-message))) | 663 | (write-region "" nil file nil 'no-message))) |
| 664 | (file-notify--test-with-events (cond | 664 | (file-notify--test-with-events (make-list n 'renamed) |
| 665 | ;; XXX Different results? | ||
| 666 | ((featurep 'kqueue) | ||
| 667 | (append (make-list n 'changed) | ||
| 668 | (make-list n 'deleted))) | ||
| 669 | (t (make-list n 'renamed))) | ||
| 670 | (let ((x-file-list x-file-list) | 665 | (let ((x-file-list x-file-list) |
| 671 | (y-file-list y-file-list)) | 666 | (y-file-list y-file-list)) |
| 672 | (while (and x-file-list y-file-list) | 667 | (while (and x-file-list y-file-list) |
| @@ -676,6 +671,9 @@ Don't wait longer than timeout seconds for the events to be delivered." | |||
| 676 | (delete-file file)))) | 671 | (delete-file file)))) |
| 677 | (file-notify--test-cleanup))) | 672 | (file-notify--test-cleanup))) |
| 678 | 673 | ||
| 674 | (file-notify--deftest-remote file-notify-test06-many-events | ||
| 675 | "Check that events are not dropped remote directories.") | ||
| 676 | |||
| 679 | (defun file-notify-test-all (&optional interactive) | 677 | (defun file-notify-test-all (&optional interactive) |
| 680 | "Run all tests for \\[file-notify]." | 678 | "Run all tests for \\[file-notify]." |
| 681 | (interactive "p") | 679 | (interactive "p") |