File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -206,6 +206,9 @@ static enum fsmonitor_cookie_item_result with_lock__wait_for_cookie(
206206 close (fd );
207207 unlink (cookie_pathname .buf );
208208
209+ /* The listener callback takes main_lock, so this must not block. */
210+ fsm_listen__flush_async (state );
211+
209212 /*
210213 * Wait for the listener thread to observe the cookie file.
211214 * Time out after a short interval so that the client
Original file line number Diff line number Diff line change @@ -82,6 +82,7 @@ CFRunLoopRef CFRunLoopGetCurrent(void);
8282extern CFStringRef kCFRunLoopDefaultMode ;
8383void FSEventStreamSetDispatchQueue (FSEventStreamRef stream , dispatch_queue_t q );
8484unsigned char FSEventStreamStart (FSEventStreamRef stream );
85+ FSEventStreamEventId FSEventStreamFlushAsync (FSEventStreamRef stream );
8586void FSEventStreamStop (FSEventStreamRef stream );
8687void FSEventStreamInvalidate (FSEventStreamRef stream );
8788void FSEventStreamRelease (FSEventStreamRef stream );
Original file line number Diff line number Diff line change @@ -496,6 +496,11 @@ void fsm_listen__stop_async(struct fsmonitor_daemon_state *state)
496496 pthread_mutex_unlock (& data -> dq_lock );
497497}
498498
499+ void fsm_listen__flush_async (struct fsmonitor_daemon_state * state )
500+ {
501+ FSEventStreamFlushAsync (state -> listen_data -> stream );
502+ }
503+
499504void fsm_listen__loop (struct fsmonitor_daemon_state * state )
500505{
501506 struct fsm_listen_data * data ;
Original file line number Diff line number Diff line change @@ -493,6 +493,10 @@ void fsm_listen__stop_async(struct fsmonitor_daemon_state *state)
493493 state -> listen_data -> shutdown = SHUTDOWN_STOP ;
494494}
495495
496+ void fsm_listen__flush_async (struct fsmonitor_daemon_state * state UNUSED )
497+ {
498+ }
499+
496500/*
497501 * Process a single inotify event and queue for publication.
498502 */
Original file line number Diff line number Diff line change @@ -290,6 +290,10 @@ void fsm_listen__stop_async(struct fsmonitor_daemon_state *state)
290290 SetEvent (state -> listen_data -> hListener [LISTENER_SHUTDOWN ]);
291291}
292292
293+ void fsm_listen__flush_async (struct fsmonitor_daemon_state * state UNUSED )
294+ {
295+ }
296+
293297static struct one_watch * create_watch (const char * path )
294298{
295299 struct one_watch * watch = NULL ;
Original file line number Diff line number Diff line change @@ -38,6 +38,12 @@ void fsm_listen__dtor(struct fsmonitor_daemon_state *state);
3838 */
3939void fsm_listen__loop (struct fsmonitor_daemon_state * state );
4040
41+ /*
42+ * Prompt the listener to deliver queued filesystem events, if supported.
43+ * This does not wait for the events to be processed.
44+ */
45+ void fsm_listen__flush_async (struct fsmonitor_daemon_state * state );
46+
4147/*
4248 * Gently request that the fsmonitor listener thread shutdown.
4349 * It does not wait for it to stop. The caller should do a JOIN
You can’t perform that action at this time.
0 commit comments