summaryrefslogtreecommitdiff
path: root/src/lib/eio
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-01-04 16:01:40 -0800
committerCedric BAIL <cedric.bail@free.fr>2019-01-16 14:33:16 -0800
commit04090f3e7acef5ca47b7b44033dbf3312ae8b6d1 (patch)
tree9cf300b9ceec2901a1938e7e9c0f2a32bc0a2c82 /src/lib/eio
parent54729224672db79ff2ec09307ac862ddf494f131 (diff)
eio: remove use of eina_promise_data_set.
eina_promise_data_set is a misleading API and result in conflicted use by multiple independent piece of code leading to bug and crash. It is also not necessary and we can avoid using it completely. Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Differential Revision: https://phab.enlightenment.org/D7572
Diffstat (limited to 'src/lib/eio')
-rw-r--r--src/lib/eio/efl_io_manager.c46
-rw-r--r--src/lib/eio/eio_model.c23
-rw-r--r--src/lib/eio/eio_private.h16
3 files changed, 44 insertions, 41 deletions
diff --git a/src/lib/eio/efl_io_manager.c b/src/lib/eio/efl_io_manager.c
index 9dcdfee..110f01c 100644
--- a/src/lib/eio/efl_io_manager.c
+++ b/src/lib/eio/efl_io_manager.c
@@ -119,7 +119,7 @@ _efl_io_manager_direct_ls(const Eo *obj,
119 Eina_Future *future; 119 Eina_Future *future;
120 Eio_File *h; 120 Eio_File *h;
121 121
122 p = eina_promise_new(efl_loop_future_scheduler_get(obj), _efl_io_manager_future_cancel, NULL); 122 p = efl_loop_promise_new(obj, NULL, NULL, NULL);
123 if (!p) return NULL; 123 if (!p) return NULL;
124 future = eina_future_new(p); 124 future = eina_future_new(p);
125 125
@@ -143,9 +143,8 @@ _efl_io_manager_direct_ls(const Eo *obj,
143 143
144 ecore_thread_local_data_add(h->thread, ".info", info, NULL, EINA_TRUE); 144 ecore_thread_local_data_add(h->thread, ".info", info, NULL, EINA_TRUE);
145 ecore_thread_local_data_add(h->thread, ".info_data", info_data, info_free_cb, EINA_TRUE); 145 ecore_thread_local_data_add(h->thread, ".info_data", info_data, info_free_cb, EINA_TRUE);
146 eina_promise_data_set(p, h);
147 146
148 return efl_future_then(obj, future); 147 return _efl_io_manager_future(obj, future, h);
149 148
150 end: 149 end:
151 return future; 150 return future;
@@ -162,7 +161,7 @@ _efl_io_manager_stat_ls(const Eo *obj,
162 Eina_Future *future; 161 Eina_Future *future;
163 Eio_File *h; 162 Eio_File *h;
164 163
165 p = eina_promise_new(efl_loop_future_scheduler_get(obj), _efl_io_manager_future_cancel, NULL); 164 p = efl_loop_promise_new(obj, NULL, NULL, NULL);
166 if (!p) return NULL; 165 if (!p) return NULL;
167 future = eina_future_new(p); 166 future = eina_future_new(p);
168 167
@@ -186,9 +185,8 @@ _efl_io_manager_stat_ls(const Eo *obj,
186 185
187 ecore_thread_local_data_add(h->thread, ".info", info, NULL, EINA_TRUE); 186 ecore_thread_local_data_add(h->thread, ".info", info, NULL, EINA_TRUE);
188 ecore_thread_local_data_add(h->thread, ".info_data", info_data, info_free_cb, EINA_TRUE); 187 ecore_thread_local_data_add(h->thread, ".info_data", info_data, info_free_cb, EINA_TRUE);
189 eina_promise_data_set(p, h);
190 188
191 return efl_future_then(obj, future); 189 return _efl_io_manager_future(obj, future, h);
192 190
193 end: 191 end:
194 return future; 192 return future;
@@ -204,7 +202,7 @@ _efl_io_manager_ls(const Eo *obj,
204 Eina_Future *future; 202 Eina_Future *future;
205 Eio_File *h; 203 Eio_File *h;
206 204
207 p = eina_promise_new(efl_loop_future_scheduler_get(obj), _efl_io_manager_future_cancel, NULL); 205 p = efl_loop_promise_new(obj, NULL, NULL, NULL);
208 if (!p) return NULL; 206 if (!p) return NULL;
209 future = eina_future_new(p); 207 future = eina_future_new(p);
210 208
@@ -217,9 +215,8 @@ _efl_io_manager_ls(const Eo *obj,
217 215
218 ecore_thread_local_data_add(h->thread, ".paths", paths, NULL, EINA_TRUE); 216 ecore_thread_local_data_add(h->thread, ".paths", paths, NULL, EINA_TRUE);
219 ecore_thread_local_data_add(h->thread, ".paths_data", paths_data, paths_free_cb, EINA_TRUE); 217 ecore_thread_local_data_add(h->thread, ".paths_data", paths_data, paths_free_cb, EINA_TRUE);
220 eina_promise_data_set(p, h);
221 218
222 return efl_future_then(obj, future); 219 return _efl_io_manager_future(obj, future, h);
223 220
224 end: 221 end:
225 return future; 222 return future;
@@ -256,7 +253,7 @@ _efl_io_manager_stat(const Eo *obj,
256 Eina_Future *future; 253 Eina_Future *future;
257 Eio_File *h; 254 Eio_File *h;
258 255
259 p = eina_promise_new(efl_loop_future_scheduler_get(obj), _efl_io_manager_future_cancel, NULL); 256 p = efl_loop_promise_new(obj, NULL, NULL, NULL);
260 if (!p) return NULL; 257 if (!p) return NULL;
261 future = eina_future_new(p); 258 future = eina_future_new(p);
262 259
@@ -265,9 +262,8 @@ _efl_io_manager_stat(const Eo *obj,
265 _future_file_error_cb, 262 _future_file_error_cb,
266 p); 263 p);
267 if (!h) goto end; 264 if (!h) goto end;
268 eina_promise_data_set(p, h);
269 265
270 return efl_future_then(obj, future); 266 return _efl_io_manager_future(obj, future, h);
271 267
272 end: 268 end:
273 return future; 269 return future;
@@ -285,7 +281,7 @@ _efl_io_manager_xattr_ls(const Eo *obj,
285 Eina_Future *future; 281 Eina_Future *future;
286 Eio_File *h; 282 Eio_File *h;
287 283
288 p = eina_promise_new(efl_loop_future_scheduler_get(obj), _efl_io_manager_future_cancel, NULL); 284 p = efl_loop_promise_new(obj, NULL, NULL, NULL);
289 if (!p) return NULL; 285 if (!p) return NULL;
290 future = eina_future_new(p); 286 future = eina_future_new(p);
291 287
@@ -299,9 +295,8 @@ _efl_io_manager_xattr_ls(const Eo *obj,
299 // There is no race condition here as all the callback are called in the main loop after this 295 // There is no race condition here as all the callback are called in the main loop after this
300 ecore_thread_local_data_add(h->thread, ".paths", paths, NULL, EINA_TRUE); 296 ecore_thread_local_data_add(h->thread, ".paths", paths, NULL, EINA_TRUE);
301 ecore_thread_local_data_add(h->thread, ".paths_data", paths_data, paths_free_cb, EINA_TRUE); 297 ecore_thread_local_data_add(h->thread, ".paths_data", paths_data, paths_free_cb, EINA_TRUE);
302 eina_promise_data_set(p, h);
303 298
304 return efl_future_then(obj, future); 299 return _efl_io_manager_future(obj, future, h);
305 300
306 end: 301 end:
307 return efl_future_then(obj, future);; 302 return efl_future_then(obj, future);;
@@ -336,7 +331,7 @@ _efl_io_manager_xattr_set(Eo *obj,
336 Eina_Future *future; 331 Eina_Future *future;
337 Eio_File *h; 332 Eio_File *h;
338 333
339 p = eina_promise_new(efl_loop_future_scheduler_get(obj), _efl_io_manager_future_cancel, NULL); 334 p = efl_loop_promise_new(obj, NULL, NULL, NULL);
340 if (!p) return NULL; 335 if (!p) return NULL;
341 future = eina_future_new(p); 336 future = eina_future_new(p);
342 337
@@ -348,9 +343,8 @@ _efl_io_manager_xattr_set(Eo *obj,
348 _future_file_error_cb, 343 _future_file_error_cb,
349 p); 344 p);
350 if (!h) goto end; 345 if (!h) goto end;
351 eina_promise_data_set(p, h);
352 346
353 return efl_future_then(obj, future); 347 return _efl_io_manager_future(obj, future, h);
354 348
355 end: 349 end:
356 return future; 350 return future;
@@ -366,7 +360,7 @@ _efl_io_manager_xattr_get(const Eo *obj,
366 Eina_Future *future; 360 Eina_Future *future;
367 Eio_File *h; 361 Eio_File *h;
368 362
369 p = eina_promise_new(efl_loop_future_scheduler_get(obj), _efl_io_manager_future_cancel, NULL); 363 p = efl_loop_promise_new(obj, NULL, NULL, NULL);
370 if (!p) return NULL; 364 if (!p) return NULL;
371 future = eina_future_new(p); 365 future = eina_future_new(p);
372 366
@@ -375,10 +369,8 @@ _efl_io_manager_xattr_get(const Eo *obj,
375 _future_file_error_cb, 369 _future_file_error_cb,
376 p); 370 p);
377 if (!h) goto end; 371 if (!h) goto end;
378 eina_promise_data_set(p, h);
379 372
380 /* XXX const */ 373 return _efl_io_manager_future(obj, future, h);
381 return efl_future_then((Eo *)obj, future);
382 374
383 end: 375 end:
384 return future; 376 return future;
@@ -405,7 +397,7 @@ _efl_io_manager_open(const Eo *obj,
405 Eina_Future *future; 397 Eina_Future *future;
406 Eio_File *h; 398 Eio_File *h;
407 399
408 p = eina_promise_new(efl_loop_future_scheduler_get(obj), _efl_io_manager_future_cancel, NULL); 400 p = efl_loop_promise_new(obj, NULL, NULL, NULL);
409 if (!p) return NULL; 401 if (!p) return NULL;
410 future = eina_future_new(p); 402 future = eina_future_new(p);
411 403
@@ -414,9 +406,8 @@ _efl_io_manager_open(const Eo *obj,
414 _future_file_error_cb, 406 _future_file_error_cb,
415 p); 407 p);
416 if (!h) goto end; 408 if (!h) goto end;
417 eina_promise_data_set(p, h);
418 409
419 return efl_future_then(obj, future); 410 return _efl_io_manager_future(obj, future, h);
420 411
421 end: 412 end:
422 return future; 413 return future;
@@ -431,7 +422,7 @@ _efl_io_manager_close(const Eo *obj,
431 Eina_Future *future; 422 Eina_Future *future;
432 Eio_File *h; 423 Eio_File *h;
433 424
434 p = eina_promise_new(efl_loop_future_scheduler_get(obj), _efl_io_manager_future_cancel, NULL); 425 p = efl_loop_promise_new(obj, NULL, NULL, NULL);
435 if (!p) return NULL; 426 if (!p) return NULL;
436 future = eina_future_new(p); 427 future = eina_future_new(p);
437 428
@@ -440,9 +431,8 @@ _efl_io_manager_close(const Eo *obj,
440 _future_file_error_cb, 431 _future_file_error_cb,
441 p); 432 p);
442 if (!h) goto end; 433 if (!h) goto end;
443 eina_promise_data_set(p, h);
444 434
445 return efl_future_then(obj, future); 435 return _efl_io_manager_future(obj, future, h);
446 436
447 end: 437 end:
448 return future; 438 return future;
diff --git a/src/lib/eio/eio_model.c b/src/lib/eio/eio_model.c
index c6e03e6..d080830 100644
--- a/src/lib/eio/eio_model.c
+++ b/src/lib/eio/eio_model.c
@@ -406,10 +406,12 @@ _delayed_flush(void *data EINA_UNUSED, const Efl_Event *ev)
406 efl_event_callback_del(ev->object, EFL_LOOP_EVENT_IDLE, _delayed_flush, NULL); 406 efl_event_callback_del(ev->object, EFL_LOOP_EVENT_IDLE, _delayed_flush, NULL);
407} 407}
408 408
409static void 409static Eina_Value
410_cancel_request(void *data, const Eina_Promise *dead_ptr EINA_UNUSED) 410_cancel_request(Efl_Loop *loop EINA_UNUSED, void *data, Eina_Error error)
411{ 411{
412 delayed_queue = eina_list_remove_list(delayed_queue, data); 412 delayed_queue = eina_list_remove_list(delayed_queue, data);
413
414 return eina_value_error_init(error);
413} 415}
414 416
415static Eina_Future * 417static Eina_Future *
@@ -417,7 +419,7 @@ _build_delay(Efl_Loop *loop)
417{ 419{
418 Eina_Promise *p; 420 Eina_Promise *p;
419 421
420 p = eina_promise_new(efl_loop_future_scheduler_get(loop), _cancel_request, NULL); 422 p = eina_promise_new(efl_loop_future_scheduler_get(loop), NULL, NULL);
421 423
422 if (!delayed_queue) 424 if (!delayed_queue)
423 { 425 {
@@ -428,9 +430,10 @@ _build_delay(Efl_Loop *loop)
428 } 430 }
429 431
430 delayed_queue = eina_list_append(delayed_queue, p); 432 delayed_queue = eina_list_append(delayed_queue, p);
431 eina_promise_data_set(p, eina_list_last(delayed_queue));
432 433
433 return eina_future_new(p); 434 return efl_future_then(loop, eina_future_new(p),
435 .error = _cancel_request,
436 .data = eina_list_last(delayed_queue));
434} 437}
435 438
436static void 439static void
@@ -682,7 +685,7 @@ _eio_model_efl_model_property_set(Eo *obj,
682 685
683 if (finalized) 686 if (finalized)
684 { 687 {
685 Eina_Promise *p = eina_promise_new(efl_loop_future_scheduler_get(obj), _efl_io_manager_future_cancel, NULL); 688 Eina_Promise *p = efl_loop_promise_new(obj, NULL, NULL, NULL);
686 f = eina_future_new(p); 689 f = eina_future_new(p);
687 690
688 pd->request.move = eio_file_move(pd->path, path, 691 pd->request.move = eio_file_move(pd->path, path,
@@ -690,17 +693,17 @@ _eio_model_efl_model_property_set(Eo *obj,
690 _eio_move_done_cb, _eio_file_error_cb, p); 693 _eio_move_done_cb, _eio_file_error_cb, p);
691 694
692 ecore_thread_local_data_add(pd->request.move->thread, ".pd", pd, NULL, EINA_TRUE); 695 ecore_thread_local_data_add(pd->request.move->thread, ".pd", pd, NULL, EINA_TRUE);
693 eina_promise_data_set(p, pd->request.move); 696
697 f = _efl_io_manager_future(obj, f, pd->request.move);
694 698
695 // FIXME: turn on monitor in the finalize stage or after move 699 // FIXME: turn on monitor in the finalize stage or after move
696 } 700 }
697 else 701 else
698 { 702 {
699 f = efl_loop_future_resolved(obj, 703 f = efl_loop_future_resolved(obj, eina_value_string_init(pd->path));
700 eina_value_string_init(pd->path));
701 } 704 }
702 705
703 return efl_future_then(obj, f); 706 return f;
704 707
705 on_error: 708 on_error:
706 return efl_loop_future_rejected(obj, err); 709 return efl_loop_future_rejected(obj, err);
diff --git a/src/lib/eio/eio_private.h b/src/lib/eio/eio_private.h
index 7e86566..a6cd4cc 100644
--- a/src/lib/eio/eio_private.h
+++ b/src/lib/eio/eio_private.h
@@ -545,10 +545,20 @@ Eio_File * _eio_file_xattr(const char *path,
545void _eio_string_notify(void *data, Ecore_Thread *thread EINA_UNUSED, void *msg_data); 545void _eio_string_notify(void *data, Ecore_Thread *thread EINA_UNUSED, void *msg_data);
546void _eio_direct_notify(void *data, Ecore_Thread *thread EINA_UNUSED, void *msg_data); 546void _eio_direct_notify(void *data, Ecore_Thread *thread EINA_UNUSED, void *msg_data);
547 547
548static inline void 548static inline Eina_Value
549_efl_io_manager_future_cancel(void *data, const Eina_Promise *dead_ptr EINA_UNUSED) 549_efl_io_manager_future_cancel(Eo *o EINA_UNUSED, void *data, Eina_Error error)
550{ 550{
551 eio_file_cancel(data); 551 if (error == ECANCELED) eio_file_cancel(data);
552
553 return eina_value_error_init(error);
554}
555
556static inline Eina_Future *
557_efl_io_manager_future(const Eo *o, Eina_Future *f, Eio_File *h)
558{
559 return efl_future_then(o, f,
560 .error = _efl_io_manager_future_cancel,
561 .data = h);
552} 562}
553 563
554EINA_VALUE_STRUCT_DESC_DEFINE(_eina_stat_desc, 564EINA_VALUE_STRUCT_DESC_DEFINE(_eina_stat_desc,