diff --git a/legacy/evas/ChangeLog b/legacy/evas/ChangeLog index f6c0754195..3dc79f04cf 100644 --- a/legacy/evas/ChangeLog +++ b/legacy/evas/ChangeLog @@ -953,3 +953,7 @@ 2012-08-07 Cedric Bail * Properly warn when user try to link object from different canvas. + +2012-08-13 Carsten Haitzler (The Rasterman) + + * Fix async fd stuff to generate new pipe after a fork (pid mismatch) diff --git a/legacy/evas/src/lib/canvas/evas_async_events.c b/legacy/evas/src/lib/canvas/evas_async_events.c index bd2e3a8b5c..1002d3d53b 100644 --- a/legacy/evas/src/lib/canvas/evas_async_events.c +++ b/legacy/evas/src/lib/canvas/evas_async_events.c @@ -19,6 +19,7 @@ static int _fd_write = -1; static int _fd_read = -1; +static pid_t _fd_pid = 0; static int _init_evas_event = 0; @@ -40,6 +41,8 @@ evas_async_events_init(void) _init_evas_event++; if (_init_evas_event > 1) return _init_evas_event; + _fd_pid = getpid(); + if (pipe(filedes) == -1) { _init_evas_event = 0; @@ -68,12 +71,23 @@ evas_async_events_shutdown(void) return _init_evas_event; } +static void +_evas_async_events_fork_handle(void) +{ + int i, count = _init_evas_event; + + if (getpid() == _fd_pid) return; + for (i = 0; i < count; i++) evas_async_events_shutdown(); + for (i = 0; i < count; i++) evas_async_events_init(); +} + #endif EAPI int evas_async_events_fd_get(void) { #ifdef BUILD_ASYNC_EVENTS + _evas_async_events_fork_handle(); return _fd_read; #else return -1; @@ -90,6 +104,8 @@ evas_async_events_process(void) if (_fd_read == -1) return 0; + _evas_async_events_fork_handle(); + do { check = read(_fd_read, &ev, sizeof (Evas_Event_Async *)); @@ -134,6 +150,8 @@ evas_async_events_put(const void *target, Evas_Callback_Type type, void *event_i if (!func) return 0; if (_fd_write == -1) return 0; + _evas_async_events_fork_handle(); + ev = calloc(1, sizeof (Evas_Event_Async)); if (!ev) return 0;