aboutsummaryrefslogtreecommitdiffstats
path: root/src/kqueue.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/kqueue.c')
-rw-r--r--src/kqueue.c25
1 files changed, 19 insertions, 6 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]). */
36static Lisp_Object watch_list; 36static 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). */
40static 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). */
40Lisp_Object 44Lisp_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
444globals_of_kqueue (void) 456globals_of_kqueue (void)
445{ 457{
446 watch_list = Qnil; 458 watch_list = Qnil;
459 pending_events = Qnil;
447} 460}
448 461
449void 462void