From 5117d0f912bcd4bb79d9ff74413553b50ce8899b Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Tue, 22 Feb 2011 06:09:46 +0000 Subject: [PATCH] Fix: ecore-file inotify fd would be duplicated in children on fork. Have it detecti this on next monitor add and re-init the inotify fd and fd handler. SVN revision: 57228 --- legacy/ecore/ChangeLog | 6 ++++++ .../src/lib/ecore_file/ecore_file_monitor_inotify.c | 13 ++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/legacy/ecore/ChangeLog b/legacy/ecore/ChangeLog index f6febcf322..8b9d474b95 100644 --- a/legacy/ecore/ChangeLog +++ b/legacy/ecore/ChangeLog @@ -58,3 +58,9 @@ * Remove 300 second timeout so large downloads work in ecore_con. +2011-02-22 Carsten Haitzler (The Rasterman) + + * Fix: ecore-file inotify fd would be duplicated in children + on fork. Have it detecti this on next monitor add and re-init the + inotify fd and fd handler. + diff --git a/legacy/ecore/src/lib/ecore_file/ecore_file_monitor_inotify.c b/legacy/ecore/src/lib/ecore_file/ecore_file_monitor_inotify.c index e9bb595695..0491f294c8 100644 --- a/legacy/ecore/src/lib/ecore_file/ecore_file_monitor_inotify.c +++ b/legacy/ecore/src/lib/ecore_file/ecore_file_monitor_inotify.c @@ -47,6 +47,7 @@ struct _Ecore_File_Monitor_Inotify static Ecore_Fd_Handler *_fdh = NULL; static Ecore_File_Monitor *_monitors = NULL; +static pid_t _inotify_fd_pid = -1; static Eina_Bool _ecore_file_monitor_inotify_handler(void *data, Ecore_Fd_Handler *fdh); static Ecore_File_Monitor *_ecore_file_monitor_inotify_monitor_find(int wd); @@ -64,7 +65,7 @@ ecore_file_monitor_inotify_init(void) fd = inotify_init(); if (fd < 0) return 0; - + _fdh = ecore_main_fd_handler_add(fd, ECORE_FD_READ, _ecore_file_monitor_inotify_handler, NULL, NULL, NULL); if (!_fdh) @@ -73,6 +74,7 @@ ecore_file_monitor_inotify_init(void) return 0; } + _inotify_fd_pid = getpid(); return 1; } @@ -90,6 +92,7 @@ ecore_file_monitor_inotify_shutdown(void) ecore_main_fd_handler_del(_fdh); close(fd); } + _inotify_fd_pid = -1; return 1; } @@ -103,6 +106,14 @@ ecore_file_monitor_inotify_add(const char *path, Ecore_File_Monitor *em; int len; + if (_inotify_fd_pid == -1) return NULL; + + if (_inotify_fd_pid != getpid()) + { + ecore_file_monitor_inotify_shutdown(); + ecore_file_monitor_inotify_init(); + } + em = calloc(1, sizeof(Ecore_File_Monitor_Inotify)); if (!em) return NULL;