summaryrefslogtreecommitdiff
path: root/src/lib/evas
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2017-11-07 15:45:03 -0800
committerCedric BAIL <cedric@osg.samsung.com>2017-11-07 16:08:39 -0800
commit73e6404b1a89b26518f61b7a163e7dc9066bd8ca (patch)
tree36f041212e160a781ff2d0f584a1d1c2a3da2fe6 /src/lib/evas
parentee65414ef6b75a61044227a9a4ab10201cee787d (diff)
evas: rely on ecore to reset ecore_pipe for evas_async_events.
Ecore being a dependency of evas, let's make our life easier and rely on ecore to tell us when to reset pipe due to a fork instead of trying to guess.
Diffstat (limited to 'src/lib/evas')
-rw-r--r--src/lib/evas/canvas/evas_async_events.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/lib/evas/canvas/evas_async_events.c b/src/lib/evas/canvas/evas_async_events.c
index 58f26fb52e..ad03284b83 100644
--- a/src/lib/evas/canvas/evas_async_events.c
+++ b/src/lib/evas/canvas/evas_async_events.c
@@ -50,7 +50,6 @@ static int _thread_id_update = 0;
50 50
51static Eina_Bool _write_error = EINA_TRUE; 51static Eina_Bool _write_error = EINA_TRUE;
52static Eina_Bool _read_error = EINA_TRUE; 52static Eina_Bool _read_error = EINA_TRUE;
53static pid_t _fd_pid = 0;
54 53
55static Eina_Spinlock async_lock; 54static Eina_Spinlock async_lock;
56static Eina_Inarray async_queue; 55static Eina_Inarray async_queue;
@@ -105,6 +104,14 @@ _async_events_pipe_read_cb(void *data EINA_UNUSED, void *buf, unsigned int len)
105 _evas_async_events_fd_blocking_set(EINA_FALSE); 104 _evas_async_events_fd_blocking_set(EINA_FALSE);
106} 105}
107 106
107static void
108_evas_async_events_fork_handle(void *data EINA_UNUSED)
109{
110 ecore_pipe_del(_async_pipe);
111 _async_pipe = ecore_pipe_add(_async_events_pipe_read_cb, NULL);
112 ecore_pipe_freeze(_async_pipe);
113}
114
108int 115int
109evas_async_events_init(void) 116evas_async_events_init(void)
110{ 117{
@@ -117,7 +124,7 @@ evas_async_events_init(void)
117 return 0; 124 return 0;
118 } 125 }
119 126
120 _fd_pid = getpid(); 127 ecore_fork_reset_callback_add(_evas_async_events_fork_handle, NULL);
121 128
122 _async_pipe = ecore_pipe_add(_async_events_pipe_read_cb, NULL); 129 _async_pipe = ecore_pipe_add(_async_events_pipe_read_cb, NULL);
123 if ( !_async_pipe ) 130 if ( !_async_pipe )
@@ -163,6 +170,8 @@ evas_async_events_shutdown(void)
163 eina_spinlock_free(&async_lock); 170 eina_spinlock_free(&async_lock);
164 eina_inarray_flush(&async_queue); 171 eina_inarray_flush(&async_queue);
165 172
173 ecore_fork_reset_callback_del(_evas_async_events_fork_handle, NULL);
174
166 ecore_pipe_del(_async_pipe); 175 ecore_pipe_del(_async_pipe);
167 _read_error = EINA_TRUE; 176 _read_error = EINA_TRUE;
168 _write_error = EINA_TRUE; 177 _write_error = EINA_TRUE;
@@ -171,20 +180,9 @@ evas_async_events_shutdown(void)
171 return _init_evas_event; 180 return _init_evas_event;
172} 181}
173 182
174static void
175_evas_async_events_fork_handle(void)
176{
177 int i, count = _init_evas_event;
178
179 if (getpid() == _fd_pid) return;
180 for (i = 0; i < count; i++) evas_async_events_shutdown();
181 for (i = 0; i < count; i++) evas_async_events_init();
182}
183
184EAPI int 183EAPI int
185evas_async_events_fd_get(void) 184evas_async_events_fd_get(void)
186{ 185{
187 _evas_async_events_fork_handle();
188 return ecore_pipe_read_fd(_async_pipe); 186 return ecore_pipe_read_fd(_async_pipe);
189} 187}
190 188
@@ -192,8 +190,8 @@ EAPI int
192evas_async_events_process(void) 190evas_async_events_process(void)
193{ 191{
194 int count = 0; 192 int count = 0;
193
195 if (_read_error) return -1; 194 if (_read_error) return -1;
196 _evas_async_events_fork_handle();
197 195
198 _event_count = 0; 196 _event_count = 0;
199 while (ecore_pipe_wait(_async_pipe, 1, 0.0)) 197 while (ecore_pipe_wait(_async_pipe, 1, 0.0))
@@ -224,8 +222,6 @@ evas_async_events_process_blocking(void)
224 int ret; 222 int ret;
225 if (_read_error) return -1; 223 if (_read_error) return -1;
226 224
227 _evas_async_events_fork_handle();
228
229 _evas_async_events_fd_blocking_set(EINA_TRUE); 225 _evas_async_events_fd_blocking_set(EINA_TRUE);
230 226
231 _event_count = 0; 227 _event_count = 0;
@@ -247,8 +243,6 @@ evas_async_events_put(const void *target, Evas_Callback_Type type, void *event_i
247 if (!func) return EINA_FALSE; 243 if (!func) return EINA_FALSE;
248 if (_write_error) return EINA_FALSE; 244 if (_write_error) return EINA_FALSE;
249 245
250 _evas_async_events_fork_handle();
251
252 eina_spinlock_take(&async_lock); 246 eina_spinlock_take(&async_lock);
253 247
254 count = async_queue.len; 248 count = async_queue.len;