summaryrefslogtreecommitdiff
path: root/src/lib/ecore_x
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2018-01-22 16:09:00 -0500
committerMike Blumenkrantz <zmike@osg.samsung.com>2018-01-22 17:34:37 -0500
commit7c087d209a8564a0fc460edf3924d81100a5212d (patch)
tree4bc7e6dfd677194427a2daa220345c592399afa7 /src/lib/ecore_x
parentd555c6c90377bad3a38790bd61772ab3062ab163 (diff)
ecore-x: perform internal shutdown on io error if callback is set
avoid crashing in callback when referencing dead display or handling events @fix
Diffstat (limited to 'src/lib/ecore_x')
-rw-r--r--src/lib/ecore_x/ecore_x.c47
-rw-r--r--src/lib/ecore_x/ecore_x_error.c6
-rw-r--r--src/lib/ecore_x/ecore_x_private.h1
3 files changed, 33 insertions, 21 deletions
diff --git a/src/lib/ecore_x/ecore_x.c b/src/lib/ecore_x/ecore_x.c
index ff213a7784..3dab2b81cc 100644
--- a/src/lib/ecore_x/ecore_x.c
+++ b/src/lib/ecore_x/ecore_x.c
@@ -780,14 +780,11 @@ ecore_x_init_from_display(Ecore_X_Display *display)
780 return --_ecore_x_init_count; 780 return --_ecore_x_init_count;
781} 781}
782 782
783static int 783int
784_ecore_x_shutdown(int close_display) 784_ecore_x_shutdown(void)
785{ 785{
786 if (--_ecore_x_init_count != 0)
787 return _ecore_x_init_count;
788
789 if (!_ecore_x_disp) 786 if (!_ecore_x_disp)
790 return _ecore_x_init_count; 787 return 0;
791 788
792 LOGFN(__FILE__, __LINE__, __FUNCTION__); 789 LOGFN(__FILE__, __LINE__, __FUNCTION__);
793 790
@@ -854,19 +851,9 @@ _ecore_x_shutdown(int close_display)
854 ECORE_X_EVENT_PRESENT_COMPLETE, 851 ECORE_X_EVENT_PRESENT_COMPLETE,
855 ECORE_X_EVENT_PRESENT_IDLE); 852 ECORE_X_EVENT_PRESENT_IDLE);
856 ecore_main_fd_handler_del(_ecore_x_fd_handler_handle); 853 ecore_main_fd_handler_del(_ecore_x_fd_handler_handle);
857 if (close_display)
858 XCloseDisplay(_ecore_x_disp);
859 else
860 {
861 close(ConnectionNumber(_ecore_x_disp));
862 // FIXME: may have to clean up x display internal here
863// getting segv here? hmmm. odd. disable
864// XFree(_ecore_x_disp);
865 }
866 854
867 free(_ecore_x_event_handlers); 855 free(_ecore_x_event_handlers);
868 _ecore_x_fd_handler_handle = NULL; 856 _ecore_x_fd_handler_handle = NULL;
869 _ecore_x_disp = NULL;
870 _ecore_x_event_handlers = NULL; 857 _ecore_x_event_handlers = NULL;
871 _ecore_x_events_shutdown(); 858 _ecore_x_events_shutdown();
872 _ecore_x_input_shutdown(); 859 _ecore_x_input_shutdown();
@@ -874,6 +861,12 @@ _ecore_x_shutdown(int close_display)
874 _ecore_x_dnd_shutdown(); 861 _ecore_x_dnd_shutdown();
875 ecore_x_netwm_shutdown(); 862 ecore_x_netwm_shutdown();
876 863
864 return 0;
865}
866
867static void
868_ecore_x_shutdown2(void)
869{
877 ecore_event_shutdown(); 870 ecore_event_shutdown();
878 ecore_shutdown(); 871 ecore_shutdown();
879 872
@@ -881,8 +874,6 @@ _ecore_x_shutdown(int close_display)
881 _ecore_xlib_log_dom = -1; 874 _ecore_xlib_log_dom = -1;
882 eina_shutdown(); 875 eina_shutdown();
883 _ecore_xlib_sync = EINA_FALSE; 876 _ecore_xlib_sync = EINA_FALSE;
884
885 return _ecore_x_init_count;
886} 877}
887 878
888/** 879/**
@@ -898,7 +889,14 @@ _ecore_x_shutdown(int close_display)
898EAPI int 889EAPI int
899ecore_x_shutdown(void) 890ecore_x_shutdown(void)
900{ 891{
901 return _ecore_x_shutdown(1); 892 if (--_ecore_x_init_count != 0)
893 return _ecore_x_init_count;
894 if (_ecore_x_shutdown()) return _ecore_x_init_count;
895 if (_ecore_x_disp)
896 XCloseDisplay(_ecore_x_disp);
897 _ecore_x_disp = NULL;
898 _ecore_x_shutdown2();
899 return 0;
902} 900}
903 901
904/** 902/**
@@ -911,7 +909,16 @@ ecore_x_shutdown(void)
911EAPI int 909EAPI int
912ecore_x_disconnect(void) 910ecore_x_disconnect(void)
913{ 911{
914 return _ecore_x_shutdown(0); 912 if (--_ecore_x_init_count != 0)
913 return _ecore_x_init_count;
914 if (_ecore_x_shutdown()) return _ecore_x_init_count;
915 close(ConnectionNumber(_ecore_x_disp));
916 // FIXME: may have to clean up x display internal here
917// getting segv here? hmmm. odd. disable
918// XFree(_ecore_x_disp);
919 _ecore_x_disp = NULL;
920 _ecore_x_shutdown2();
921 return 0;
915} 922}
916 923
917/** 924/**
diff --git a/src/lib/ecore_x/ecore_x_error.c b/src/lib/ecore_x/ecore_x_error.c
index ad3d32257a..9facf0733b 100644
--- a/src/lib/ecore_x/ecore_x_error.c
+++ b/src/lib/ecore_x/ecore_x_error.c
@@ -172,7 +172,11 @@ _ecore_x_io_error_handle(Display *d)
172 if (d == _ecore_x_disp) 172 if (d == _ecore_x_disp)
173 { 173 {
174 if (_io_error_func) 174 if (_io_error_func)
175 _io_error_func(_io_error_data); 175 {
176 _ecore_x_disp = NULL;
177 _ecore_x_shutdown();
178 _io_error_func(_io_error_data);
179 }
176 else 180 else
177 exit(-1); 181 exit(-1);
178 } 182 }
diff --git a/src/lib/ecore_x/ecore_x_private.h b/src/lib/ecore_x/ecore_x_private.h
index 07c09fb16f..2254f150dc 100644
--- a/src/lib/ecore_x/ecore_x_private.h
+++ b/src/lib/ecore_x/ecore_x_private.h
@@ -395,6 +395,7 @@ Ecore_Event_Mouse_Button *_ecore_mouse_button(int event,
395void _ecore_x_modifiers_get(void); 395void _ecore_x_modifiers_get(void);
396KeySym _ecore_x_XKeycodeToKeysym(Display *display, KeyCode keycode, int index); 396KeySym _ecore_x_XKeycodeToKeysym(Display *display, KeyCode keycode, int index);
397 397
398int _ecore_x_shutdown(void);
398//#define LOGFNS 1 399//#define LOGFNS 1
399 400
400#ifdef LOGFNS 401#ifdef LOGFNS