summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2018-02-02 16:59:56 -0500
committerMike Blumenkrantz <zmike@osg.samsung.com>2018-02-02 16:59:44 -0500
commit26d73cbae1f28567673d5711e5dbbc964769aa67 (patch)
treed4ad8b8216f5e55ed7f03ebe641af8cab30d6c71
parent5760b3f335d842767139d07fe08b4157382e1ad3 (diff)
eio: make inotify monitors fork-safe
@fix
-rw-r--r--src/lib/eio/eio_monitor_inotify.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/lib/eio/eio_monitor_inotify.c b/src/lib/eio/eio_monitor_inotify.c
index 5ff54d5066..f3a83be5b7 100644
--- a/src/lib/eio/eio_monitor_inotify.c
+++ b/src/lib/eio/eio_monitor_inotify.c
@@ -157,8 +157,25 @@ _eio_inotify_handler(void *data EINA_UNUSED, Ecore_Fd_Handler *fdh)
157/** 157/**
158 * @endcond 158 * @endcond
159 */ 159 */
160static Eina_Bool reseting;
161static void
162_eio_monitor_reset()
163{
164 Eina_Hash *h = _inotify_monitors;
165 Eina_Iterator *it;
166 Eio_Monitor_Backend *backend;
160 167
161 168 _inotify_monitors = NULL;
169 reseting = 1;
170 eio_monitor_backend_shutdown();
171 eio_monitor_backend_init();
172 it = eina_hash_iterator_data_new(h);
173 EINA_ITERATOR_FOREACH(it, backend)
174 eio_monitor_backend_add(backend->parent);
175 reseting = 0;
176 eina_iterator_free(it);
177 eina_hash_free(h);
178}
162/*============================================================================* 179/*============================================================================*
163 * Global * 180 * Global *
164 *============================================================================*/ 181 *============================================================================*/
@@ -189,6 +206,8 @@ void eio_monitor_backend_init(void)
189 } 206 }
190 207
191 _inotify_monitors = eina_hash_int32_new(_eio_inotify_del); 208 _inotify_monitors = eina_hash_int32_new(_eio_inotify_del);
209 if (!reseting)
210 ecore_fork_reset_callback_add(_eio_monitor_reset, NULL);
192} 211}
193 212
194void eio_monitor_backend_shutdown(void) 213void eio_monitor_backend_shutdown(void)
@@ -207,6 +226,8 @@ void eio_monitor_backend_shutdown(void)
207 return; 226 return;
208 227
209 close(fd); 228 close(fd);
229 if (!reseting)
230 ecore_fork_reset_callback_del(_eio_monitor_reset, NULL);
210} 231}
211 232
212void eio_monitor_backend_add(Eio_Monitor *monitor) 233void eio_monitor_backend_add(Eio_Monitor *monitor)