summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Michael <cp.michael@samsung.com>2019-02-13 10:01:47 -0500
committerChristopher Michael <cp.michael@samsung.com>2019-02-13 10:01:47 -0500
commit0fed1c77ae05f540fadf422b76636591fb619ae5 (patch)
tree331dc1396cec2407f90f779d898c18b6647619ae
parent4c587ef6796077d879ec607ffaea8029a31351dd (diff)
Revert this as it should not have been pushed yet
Revert "ecore_wl2: Make our wayland socket handling thread safe" This reverts commit efa85f35f447b54a6996337a11d13e3734f110bd.
-rw-r--r--src/lib/ecore_wl2/ecore_wl2_display.c73
-rw-r--r--src/lib/ecore_wl2/ecore_wl2_private.h1
2 files changed, 40 insertions, 34 deletions
diff --git a/src/lib/ecore_wl2/ecore_wl2_display.c b/src/lib/ecore_wl2/ecore_wl2_display.c
index 8699dfaace..a3af818ca4 100644
--- a/src/lib/ecore_wl2/ecore_wl2_display.c
+++ b/src/lib/ecore_wl2/ecore_wl2_display.c
@@ -10,6 +10,7 @@
10static Eina_Hash *_server_displays = NULL; 10static Eina_Hash *_server_displays = NULL;
11static Eina_Hash *_client_displays = NULL; 11static Eina_Hash *_client_displays = NULL;
12 12
13static Eina_Bool _cb_connect_idle(void *data);
13static Eina_Bool _cb_connect_data(void *data, Ecore_Fd_Handler *hdl); 14static Eina_Bool _cb_connect_data(void *data, Ecore_Fd_Handler *hdl);
14static Eina_Bool _ecore_wl2_display_connect(Ecore_Wl2_Display *ewd, Eina_Bool sync); 15static Eina_Bool _ecore_wl2_display_connect(Ecore_Wl2_Display *ewd, Eina_Bool sync);
15 16
@@ -474,6 +475,8 @@ _recovery_timer_add(Ecore_Wl2_Display *ewd)
474 Ecore_Wl2_Window *window; 475 Ecore_Wl2_Window *window;
475 476
476 eina_hash_free_buckets(ewd->globals); 477 eina_hash_free_buckets(ewd->globals);
478 ecore_idle_enterer_del(ewd->idle_enterer);
479 ewd->idle_enterer = NULL;
477 480
478 ecore_main_fd_handler_del(ewd->fd_hdl); 481 ecore_main_fd_handler_del(ewd->fd_hdl);
479 ewd->fd_hdl = NULL; 482 ewd->fd_hdl = NULL;
@@ -525,30 +528,6 @@ _begin_recovery_maybe(Ecore_Wl2_Display *ewd, int code)
525 } 528 }
526} 529}
527 530
528static void
529_cb_connect_pre(void *data, Ecore_Fd_Handler *hdl EINA_UNUSED)
530{
531 Ecore_Wl2_Display *ewd = data;
532 int ret = 0, code;
533
534 while ((wl_display_prepare_read(ewd->wl.display) != 0) && (ret >= 0))
535 ret = wl_display_dispatch_pending(ewd->wl.display);
536
537 if (ret < 0) goto err;
538
539 ret = wl_display_get_error(ewd->wl.display);
540 if (ret < 0) goto err;
541
542 return;
543
544err:
545 code = errno;
546 if ((ret < 0) && (code != EAGAIN))
547 {
548 _begin_recovery_maybe(ewd, code);
549 }
550}
551
552static Eina_Bool 531static Eina_Bool
553_cb_connect_data(void *data, Ecore_Fd_Handler *hdl) 532_cb_connect_data(void *data, Ecore_Fd_Handler *hdl)
554{ 533{
@@ -557,20 +536,17 @@ _cb_connect_data(void *data, Ecore_Fd_Handler *hdl)
557 536
558 if (ecore_main_fd_handler_active_get(hdl, ECORE_FD_READ)) 537 if (ecore_main_fd_handler_active_get(hdl, ECORE_FD_READ))
559 { 538 {
560 ret = wl_display_read_events(ewd->wl.display); 539 ret = wl_display_dispatch(ewd->wl.display);
561 code = errno; 540 code = errno;
562 if ((ret < 0) && (code != EAGAIN)) goto err; 541 if ((ret < 0) && (code != EAGAIN)) goto err;
563 } 542 }
564 else
565 wl_display_cancel_read(ewd->wl.display);
566 543
567 wl_display_dispatch_pending(ewd->wl.display);
568 if (ecore_main_fd_handler_active_get(hdl, ECORE_FD_WRITE)) 544 if (ecore_main_fd_handler_active_get(hdl, ECORE_FD_WRITE))
569 { 545 {
570 ret = wl_display_flush(ewd->wl.display); 546 ret = wl_display_flush(ewd->wl.display);
571 code = errno; 547 code = errno;
572 if (ret >= 0) 548 if (ret >= 0)
573 ecore_main_fd_handler_active_set(hdl, ECORE_FD_READ | ECORE_FD_ALWAYS); 549 ecore_main_fd_handler_active_set(hdl, ECORE_FD_READ);
574 550
575 if ((ret < 0) && (code != EAGAIN)) goto err; 551 if ((ret < 0) && (code != EAGAIN)) goto err;
576 } 552 }
@@ -596,6 +572,34 @@ _cb_globals_hash_del(void *data)
596 free(global); 572 free(global);
597} 573}
598 574
575static Eina_Bool
576_cb_connect_idle(void *data)
577{
578 Ecore_Wl2_Display *ewd = data;
579 int ret = 0, code;
580
581 ret = wl_display_get_error(ewd->wl.display);
582 code = errno;
583 if (ret < 0) goto err;
584
585 ret = wl_display_dispatch_pending(ewd->wl.display);
586 code = errno;
587 if (ret < 0) goto err;
588
589 return ECORE_CALLBACK_RENEW;
590
591err:
592 if ((ret < 0) && (code != EAGAIN))
593 {
594 ewd->idle_enterer = NULL;
595 _begin_recovery_maybe(ewd, code);
596
597 return ECORE_CALLBACK_CANCEL;
598 }
599
600 return ECORE_CALLBACK_RENEW;
601}
602
599static Ecore_Wl2_Global * 603static Ecore_Wl2_Global *
600_ecore_wl2_global_find(Ecore_Wl2_Display *ewd, const char *interface) 604_ecore_wl2_global_find(Ecore_Wl2_Display *ewd, const char *interface)
601{ 605{
@@ -738,11 +742,10 @@ _ecore_wl2_display_connect(Ecore_Wl2_Display *ewd, Eina_Bool sync)
738 742
739 ewd->fd_hdl = 743 ewd->fd_hdl =
740 ecore_main_fd_handler_add(wl_display_get_fd(ewd->wl.display), 744 ecore_main_fd_handler_add(wl_display_get_fd(ewd->wl.display),
741 ECORE_FD_READ | ECORE_FD_WRITE | ECORE_FD_ERROR | ECORE_FD_ALWAYS, 745 ECORE_FD_READ | ECORE_FD_WRITE | ECORE_FD_ERROR,
742 _cb_connect_data, ewd, NULL, ewd); 746 _cb_connect_data, ewd, NULL, NULL);
743 747
744 ecore_main_fd_handler_prepare_callback_set 748 ewd->idle_enterer = ecore_idle_enterer_add(_cb_connect_idle, ewd);
745 (ewd->fd_hdl, _cb_connect_pre, ewd);
746 749
747 _ecore_wl2_display_event(ewd, ECORE_WL2_EVENT_CONNECT); 750 _ecore_wl2_display_event(ewd, ECORE_WL2_EVENT_CONNECT);
748 return EINA_TRUE; 751 return EINA_TRUE;
@@ -765,6 +768,8 @@ _ecore_wl2_display_cleanup(Ecore_Wl2_Display *ewd)
765 EINA_INLIST_FOREACH_SAFE(ewd->outputs, tmp, output) 768 EINA_INLIST_FOREACH_SAFE(ewd->outputs, tmp, output)
766 _ecore_wl2_output_del(output); 769 _ecore_wl2_output_del(output);
767 770
771 if (ewd->idle_enterer) ecore_idle_enterer_del(ewd->idle_enterer);
772
768 if (ewd->fd_hdl) ecore_main_fd_handler_del(ewd->fd_hdl); 773 if (ewd->fd_hdl) ecore_main_fd_handler_del(ewd->fd_hdl);
769 774
770 eina_hash_free(ewd->globals); 775 eina_hash_free(ewd->globals);
@@ -1155,7 +1160,7 @@ ecore_wl2_display_flush(Ecore_Wl2_Display *display)
1155 if (code == EAGAIN) 1160 if (code == EAGAIN)
1156 { 1161 {
1157 ecore_main_fd_handler_active_set(display->fd_hdl, 1162 ecore_main_fd_handler_active_set(display->fd_hdl,
1158 (ECORE_FD_READ | ECORE_FD_WRITE | ECORE_FD_ALWAYS)); 1163 (ECORE_FD_READ | ECORE_FD_WRITE));
1159 return; 1164 return;
1160 } 1165 }
1161 1166
diff --git a/src/lib/ecore_wl2/ecore_wl2_private.h b/src/lib/ecore_wl2/ecore_wl2_private.h
index 9b6d4f7e49..e62ea5f8ea 100644
--- a/src/lib/ecore_wl2/ecore_wl2_private.h
+++ b/src/lib/ecore_wl2/ecore_wl2_private.h
@@ -102,6 +102,7 @@ struct _Ecore_Wl2_Display
102 102
103 struct xkb_context *xkb_context; 103 struct xkb_context *xkb_context;
104 104
105 Ecore_Idle_Enterer *idle_enterer;
105 Ecore_Fd_Handler *fd_hdl; 106 Ecore_Fd_Handler *fd_hdl;
106 107
107 Eina_Hash *globals; 108 Eina_Hash *globals;