aboutsummaryrefslogtreecommitdiffstats
path: root/test/lisp
diff options
context:
space:
mode:
authorFabrice Popineau2016-03-19 14:44:53 +0200
committerEli Zaretskii2016-03-19 14:44:53 +0200
commit326fff41fa9f674d80be00b5c97c44f8043bbace (patch)
tree15f5e2fb315130ce923970d16a96c8e951914857 /test/lisp
parent2fbdb1bb4c878f8ae17bd69d1b4ff51c47497e41 (diff)
downloademacs-326fff41fa9f674d80be00b5c97c44f8043bbace.tar.gz
emacs-326fff41fa9f674d80be00b5c97c44f8043bbace.zip
Improve w32notify notifications
* src/w32notify.c (DIRWATCH_BUFFER_SIZE): New macro. (struct notification): 'terminate' is now a HANDLE. (send_notifications): Argument is now a pointer to a notification. Don't loop waiting for the notification to be acknowledged by the main thread; instead, just add the notification to the linked list of notifications waiting to be acknowledged. (watch_end): Don't close the directory handle. (watch_completion): Allocate a new notification structure to be added to the notifications set. Call ReadDirectoryChangesW immediately after adding the new notification, and before sending a message to the main thread about them. (watch_worker): Don't loop calling ReadDirectoryChangesW; instead, call it just once -- it will be called again in watch_completion. Loop waiting for the main thread's indication to terminate. (start_watching): Create the event to be used to indicate to the worker thread that its should terminate. (remove_watch): Indicate to the worker thread that it should terminate. * src/w32term.c (queue_notifications): Loop over all the notifications in the linked list, processing all of them in one go. * src/w32inevt.c (handle_file_notifications): Loop over all the notifications in the linked list. * src/w32xfns.c (init_crit): Initialize the linked list of file notifications. (delete_crit): Free the linked list of file notifications, including any unprocessed notifications left in it. * src/w32term.h (struct notifications_se): New struct. * test/lisp/filenotify-tests.el (file-notify-test02-events) (file-notify-test05-dir-validity): Add read-event calls to facilitate event recognition by the main thread in batch mode.
Diffstat (limited to 'test/lisp')
-rw-r--r--test/lisp/filenotify-tests.el15
1 files changed, 11 insertions, 4 deletions
diff --git a/test/lisp/filenotify-tests.el b/test/lisp/filenotify-tests.el
index d3610f00080..39088949b36 100644
--- a/test/lisp/filenotify-tests.el
+++ b/test/lisp/filenotify-tests.el
@@ -433,7 +433,8 @@ longer than timeout seconds for the events to be delivered."
433 (write-region 433 (write-region
434 "any text" nil file-notify--test-tmpfile nil 'no-message) 434 "any text" nil file-notify--test-tmpfile nil 'no-message)
435 (read-event nil nil file-notify--test-read-event-timeout) 435 (read-event nil nil file-notify--test-read-event-timeout)
436 (delete-directory temporary-file-directory 'recursive)) 436 (delete-directory temporary-file-directory 'recursive)
437 (read-event nil nil file-notify--test-read-event-timeout))
437 (file-notify-rm-watch file-notify--test-desc)) 438 (file-notify-rm-watch file-notify--test-desc))
438 439
439 ;; Check copy of files inside a directory. 440 ;; Check copy of files inside a directory.
@@ -475,7 +476,8 @@ longer than timeout seconds for the events to be delivered."
475 (read-event nil nil file-notify--test-read-event-timeout) 476 (read-event nil nil file-notify--test-read-event-timeout)
476 (set-file-times file-notify--test-tmpfile '(0 0)) 477 (set-file-times file-notify--test-tmpfile '(0 0))
477 (read-event nil nil file-notify--test-read-event-timeout) 478 (read-event nil nil file-notify--test-read-event-timeout)
478 (delete-directory temporary-file-directory 'recursive)) 479 (delete-directory temporary-file-directory 'recursive)
480 (read-event nil nil file-notify--test-read-event-timeout))
479 (file-notify-rm-watch file-notify--test-desc)) 481 (file-notify-rm-watch file-notify--test-desc))
480 482
481 ;; Check rename of files inside a directory. 483 ;; Check rename of files inside a directory.
@@ -509,7 +511,8 @@ longer than timeout seconds for the events to be delivered."
509 (rename-file file-notify--test-tmpfile file-notify--test-tmpfile1) 511 (rename-file file-notify--test-tmpfile file-notify--test-tmpfile1)
510 ;; After the rename, we won't get events anymore. 512 ;; After the rename, we won't get events anymore.
511 (read-event nil nil file-notify--test-read-event-timeout) 513 (read-event nil nil file-notify--test-read-event-timeout)
512 (delete-directory temporary-file-directory 'recursive)) 514 (delete-directory temporary-file-directory 'recursive)
515 (read-event nil nil file-notify--test-read-event-timeout))
513 (file-notify-rm-watch file-notify--test-desc)) 516 (file-notify-rm-watch file-notify--test-desc))
514 517
515 ;; Check attribute change. Does not work for cygwin. 518 ;; Check attribute change. Does not work for cygwin.
@@ -527,7 +530,7 @@ longer than timeout seconds for the events to be delivered."
527 ;; w32notify does not distinguish between `changed' and 530 ;; w32notify does not distinguish between `changed' and
528 ;; `attribute-changed'. 531 ;; `attribute-changed'.
529 ((string-equal (file-notify--test-library) "w32notify") 532 ((string-equal (file-notify--test-library) "w32notify")
530 '(changed changed changed changed)) 533 '(changed changed))
531 ;; For kqueue and in the remote case, `write-region' 534 ;; For kqueue and in the remote case, `write-region'
532 ;; raises also an `attribute-changed' event. 535 ;; raises also an `attribute-changed' event.
533 ((or (string-equal (file-notify--test-library) "kqueue") 536 ((or (string-equal (file-notify--test-library) "kqueue")
@@ -754,7 +757,9 @@ longer than timeout seconds for the events to be delivered."
754 (should (file-notify-valid-p file-notify--test-desc)) 757 (should (file-notify-valid-p file-notify--test-desc))
755 ;; After removing the watch, the descriptor must not be valid 758 ;; After removing the watch, the descriptor must not be valid
756 ;; anymore. 759 ;; anymore.
760 (read-event nil nil file-notify--test-read-event-timeout)
757 (file-notify-rm-watch file-notify--test-desc) 761 (file-notify-rm-watch file-notify--test-desc)
762 (read-event nil nil file-notify--test-read-event-timeout)
758 (file-notify--wait-for-events 763 (file-notify--wait-for-events
759 (file-notify--test-timeout) 764 (file-notify--test-timeout)
760 (not (file-notify-valid-p file-notify--test-desc))) 765 (not (file-notify-valid-p file-notify--test-desc)))
@@ -776,7 +781,9 @@ longer than timeout seconds for the events to be delivered."
776 (should (file-notify-valid-p file-notify--test-desc)) 781 (should (file-notify-valid-p file-notify--test-desc))
777 ;; After deleting the directory, the descriptor must not be 782 ;; After deleting the directory, the descriptor must not be
778 ;; valid anymore. 783 ;; valid anymore.
784 (read-event nil nil file-notify--test-read-event-timeout)
779 (delete-directory file-notify--test-tmpfile t) 785 (delete-directory file-notify--test-tmpfile t)
786 (read-event nil nil file-notify--test-read-event-timeout)
780 (file-notify--wait-for-events 787 (file-notify--wait-for-events
781 (file-notify--test-timeout) 788 (file-notify--test-timeout)
782 (not (file-notify-valid-p file-notify--test-desc))) 789 (not (file-notify-valid-p file-notify--test-desc)))