summaryrefslogtreecommitdiff
path: root/src/lib/ecore_con
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2015-06-25 13:18:22 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2015-06-25 13:18:22 +0900
commit6483dc3ce91f94dd147bda1080b0e923d16f4653 (patch)
tree0e1fab604f2a29c3ec98f6a5a778c59191f694f8 /src/lib/ecore_con
parentb68853fd7dda0f3532dcac3192a2b92af7cc2101 (diff)
ecore con - fix object data referencing for deleted objects
if the object has been deleted already, scope data is null. handle it correctly. this fixes a segv in the new efreetd when it starts and there is an existing efreet running thus owning the socket fails. @fix
Diffstat (limited to 'src/lib/ecore_con')
-rw-r--r--src/lib/ecore_con/ecore_con.c210
1 files changed, 124 insertions, 86 deletions
diff --git a/src/lib/ecore_con/ecore_con.c b/src/lib/ecore_con/ecore_con.c
index 941dc11cea..1582c26a2c 100644
--- a/src/lib/ecore_con/ecore_con.c
+++ b/src/lib/ecore_con/ecore_con.c
@@ -271,6 +271,7 @@ ecore_con_shutdown(void)
271 Ecore_Con_Server_Data *svr = eo_data_scope_get(obj, ECORE_CON_SERVER_CLASS); 271 Ecore_Con_Server_Data *svr = eo_data_scope_get(obj, ECORE_CON_SERVER_CLASS);
272 Ecore_Con_Event_Server_Add *ev; 272 Ecore_Con_Event_Server_Add *ev;
273 273
274 if (!svr) continue;
274 svr->delete_me = EINA_TRUE; 275 svr->delete_me = EINA_TRUE;
275 INF("svr %p is dead", svr); 276 INF("svr %p is dead", svr);
276 /* some pointer hacks here to prevent double frees if people are being stupid */ 277 /* some pointer hacks here to prevent double frees if people are being stupid */
@@ -1373,8 +1374,10 @@ _ecore_con_server_eo_base_destructor(Eo *obj, Ecore_Con_Server_Data *svr)
1373 1374
1374 ecore_con_ssl_server_shutdown(obj); 1375 ecore_con_ssl_server_shutdown(obj);
1375 free(svr->name); 1376 free(svr->name);
1377 svr->name = NULL;
1376 1378
1377 free(svr->path); 1379 free(svr->path);
1380 svr->path = NULL;
1378 1381
1379 eina_stringshare_del(svr->ip); 1382 eina_stringshare_del(svr->ip);
1380 eina_stringshare_del(svr->verify_name); 1383 eina_stringshare_del(svr->verify_name);
@@ -1394,8 +1397,9 @@ _ecore_con_server_eo_base_destructor(Eo *obj, Ecore_Con_Server_Data *svr)
1394 servers = eina_list_remove(servers, obj); 1397 servers = eina_list_remove(servers, obj);
1395 svr->data = NULL; 1398 svr->data = NULL;
1396 1399
1397end:
1398 eo_do_super(obj, ECORE_CON_SERVER_CLASS, eo_destructor()); 1400 eo_do_super(obj, ECORE_CON_SERVER_CLASS, eo_destructor());
1401end:
1402 return;
1399} 1403}
1400 1404
1401static void 1405static void
@@ -2675,21 +2679,25 @@ _ecore_con_event_client_add_free(Ecore_Con_Server *obj,
2675 Ecore_Con_Client_Data *cl = eo_data_scope_get(e->client, ECORE_CON_CLIENT_CLASS); 2679 Ecore_Con_Client_Data *cl = eo_data_scope_get(e->client, ECORE_CON_CLIENT_CLASS);
2676 Eina_Bool svrfreed = EINA_FALSE; 2680 Eina_Bool svrfreed = EINA_FALSE;
2677 2681
2678 cl->event_count = eina_list_remove(cl->event_count, e); 2682 if ((svr) && (cl))
2679 if (cl->host_server)
2680 { 2683 {
2681 Ecore_Con_Server_Data *host_server = eo_data_scope_get(cl->host_server, ECORE_CON_SERVER_CLASS); 2684 cl->event_count = eina_list_remove(cl->event_count, e);
2682 host_server->event_count = eina_list_remove(host_server->event_count, ev); 2685 if (cl->host_server)
2683 if ((!svr->event_count) && (svr->delete_me))
2684 { 2686 {
2685 _ecore_con_server_free(obj); 2687 Ecore_Con_Server_Data *host_server = eo_data_scope_get(cl->host_server, ECORE_CON_SERVER_CLASS);
2686 svrfreed = EINA_TRUE; 2688 if (host_server)
2689 host_server->event_count = eina_list_remove(host_server->event_count, ev);
2690 if ((!svr->event_count) && (svr->delete_me))
2691 {
2692 _ecore_con_server_free(obj);
2693 svrfreed = EINA_TRUE;
2694 }
2695 }
2696 if (!svrfreed)
2697 {
2698 if ((!cl->event_count) && (cl->delete_me))
2699 ecore_con_client_del(e->client);
2687 } 2700 }
2688 }
2689 if (!svrfreed)
2690 {
2691 if ((!cl->event_count) && (cl->delete_me))
2692 ecore_con_client_del(e->client);
2693 } 2701 }
2694 } 2702 }
2695 2703
@@ -2712,21 +2720,25 @@ _ecore_con_event_client_del_free(Ecore_Con_Server *obj,
2712 Ecore_Con_Client_Data *cl = eo_data_scope_get(e->client, ECORE_CON_CLIENT_CLASS); 2720 Ecore_Con_Client_Data *cl = eo_data_scope_get(e->client, ECORE_CON_CLIENT_CLASS);
2713 Eina_Bool svrfreed = EINA_FALSE; 2721 Eina_Bool svrfreed = EINA_FALSE;
2714 2722
2715 cl->event_count = eina_list_remove(cl->event_count, e); 2723 if ((svr) && (cl))
2716 if (cl->host_server)
2717 { 2724 {
2718 Ecore_Con_Server_Data *host_server = eo_data_scope_get(cl->host_server, ECORE_CON_SERVER_CLASS); 2725 cl->event_count = eina_list_remove(cl->event_count, e);
2719 host_server->event_count = eina_list_remove(host_server->event_count, ev); 2726 if (cl->host_server)
2720 if ((!svr->event_count) && (svr->delete_me))
2721 { 2727 {
2722 _ecore_con_server_free(obj); 2728 Ecore_Con_Server_Data *host_server = eo_data_scope_get(cl->host_server, ECORE_CON_SERVER_CLASS);
2723 svrfreed = EINA_TRUE; 2729 if (host_server)
2730 host_server->event_count = eina_list_remove(host_server->event_count, ev);
2731 if ((!svr->event_count) && (svr->delete_me))
2732 {
2733 _ecore_con_server_free(obj);
2734 svrfreed = EINA_TRUE;
2735 }
2736 }
2737 if (!svrfreed)
2738 {
2739 if (!cl->event_count)
2740 _ecore_con_client_free(e->client);
2724 } 2741 }
2725 }
2726 if (!svrfreed)
2727 {
2728 if (!cl->event_count)
2729 _ecore_con_client_free(e->client);
2730 } 2742 }
2731 } 2743 }
2732 ecore_con_event_client_del_free(e); 2744 ecore_con_event_client_del_free(e);
@@ -2745,25 +2757,29 @@ _ecore_con_event_client_write_free(Ecore_Con_Server *obj,
2745 Ecore_Con_Client_Data *cl = eo_data_scope_get(e->client, ECORE_CON_CLIENT_CLASS); 2757 Ecore_Con_Client_Data *cl = eo_data_scope_get(e->client, ECORE_CON_CLIENT_CLASS);
2746 Eina_Bool svrfreed = EINA_FALSE; 2758 Eina_Bool svrfreed = EINA_FALSE;
2747 2759
2748 cl->event_count = eina_list_remove(cl->event_count, e); 2760 if ((svr) && (cl))
2749 if (cl->host_server)
2750 { 2761 {
2751 Ecore_Con_Server_Data *host_server = eo_data_scope_get(cl->host_server, ECORE_CON_SERVER_CLASS); 2762 cl->event_count = eina_list_remove(cl->event_count, e);
2752 host_server->event_count = eina_list_remove(host_server->event_count, e); 2763 if (cl->host_server)
2753 if ((!svr->event_count) && (svr->delete_me))
2754 { 2764 {
2755 _ecore_con_server_free(obj); 2765 Ecore_Con_Server_Data *host_server = eo_data_scope_get(cl->host_server, ECORE_CON_SERVER_CLASS);
2756 svrfreed = EINA_TRUE; 2766 if (host_server)
2767 host_server->event_count = eina_list_remove(host_server->event_count, e);
2768 if ((!svr->event_count) && (svr->delete_me))
2769 {
2770 _ecore_con_server_free(obj);
2771 svrfreed = EINA_TRUE;
2772 }
2773 }
2774 if (!svrfreed)
2775 {
2776 Ecore_Con_Server_Data *host_server = eo_data_scope_get(cl->host_server, ECORE_CON_SERVER_CLASS);
2777 if (((!cl->event_count) && (cl->delete_me)) ||
2778 ((cl->host_server &&
2779 ((host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP ||
2780 (host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST))))
2781 ecore_con_client_del(e->client);
2757 } 2782 }
2758 }
2759 if (!svrfreed)
2760 {
2761 Ecore_Con_Server_Data *host_server = eo_data_scope_get(cl->host_server, ECORE_CON_SERVER_CLASS);
2762 if (((!cl->event_count) && (cl->delete_me)) ||
2763 ((cl->host_server &&
2764 ((host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP ||
2765 (host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST))))
2766 ecore_con_client_del(e->client);
2767 } 2783 }
2768 } 2784 }
2769 ecore_con_event_client_write_free(e); 2785 ecore_con_event_client_write_free(e);
@@ -2785,25 +2801,29 @@ _ecore_con_event_client_data_free(Ecore_Con_Server *obj,
2785 Ecore_Con_Client_Data *cl = eo_data_scope_get(e->client, ECORE_CON_CLIENT_CLASS); 2801 Ecore_Con_Client_Data *cl = eo_data_scope_get(e->client, ECORE_CON_CLIENT_CLASS);
2786 Eina_Bool svrfreed = EINA_FALSE; 2802 Eina_Bool svrfreed = EINA_FALSE;
2787 2803
2788 cl->event_count = eina_list_remove(cl->event_count, e); 2804 if ((svr) && (cl))
2789 if (cl->host_server)
2790 {
2791 Ecore_Con_Server_Data *host_server = eo_data_scope_get(cl->host_server, ECORE_CON_SERVER_CLASS);
2792 host_server->event_count = eina_list_remove(host_server->event_count, ev);
2793 }
2794 if ((!svr->event_count) && (svr->delete_me))
2795 {
2796 _ecore_con_server_free(obj);
2797 svrfreed = EINA_TRUE;
2798 }
2799 if (!svrfreed)
2800 { 2805 {
2801 Ecore_Con_Server_Data *host_server = eo_data_scope_get(cl->host_server, ECORE_CON_SERVER_CLASS); 2806 cl->event_count = eina_list_remove(cl->event_count, e);
2802 if (((!cl->event_count) && (cl->delete_me)) || 2807 if (cl->host_server)
2803 ((cl->host_server && 2808 {
2804 ((host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP || 2809 Ecore_Con_Server_Data *host_server = eo_data_scope_get(cl->host_server, ECORE_CON_SERVER_CLASS);
2805 (host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST)))) 2810 if (host_server)
2806 ecore_con_client_del(e->client); 2811 host_server->event_count = eina_list_remove(host_server->event_count, ev);
2812 }
2813 if ((!svr->event_count) && (svr->delete_me))
2814 {
2815 _ecore_con_server_free(obj);
2816 svrfreed = EINA_TRUE;
2817 }
2818 if (!svrfreed)
2819 {
2820 Ecore_Con_Server_Data *host_server = eo_data_scope_get(cl->host_server, ECORE_CON_SERVER_CLASS);
2821 if (((!cl->event_count) && (cl->delete_me)) ||
2822 ((cl->host_server &&
2823 ((host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP ||
2824 (host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST))))
2825 ecore_con_client_del(e->client);
2826 }
2807 } 2827 }
2808 } 2828 }
2809 free(e->data); 2829 free(e->data);
@@ -2823,9 +2843,12 @@ _ecore_con_event_server_add_free(void *data EINA_UNUSED,
2823 if (e->server) 2843 if (e->server)
2824 { 2844 {
2825 Ecore_Con_Server_Data *svr = eo_data_scope_get(e->server, ECORE_CON_SERVER_CLASS); 2845 Ecore_Con_Server_Data *svr = eo_data_scope_get(e->server, ECORE_CON_SERVER_CLASS);
2826 svr->event_count = eina_list_remove(svr->event_count, ev); 2846 if (svr)
2827 if ((!svr->event_count) && (svr->delete_me)) 2847 {
2828 _ecore_con_server_free(e->server); 2848 svr->event_count = eina_list_remove(svr->event_count, ev);
2849 if ((!svr->event_count) && (svr->delete_me))
2850 _ecore_con_server_free(e->server);
2851 }
2829 } 2852 }
2830 ecore_con_event_server_add_free(e); 2853 ecore_con_event_server_add_free(e);
2831 _ecore_con_event_count--; 2854 _ecore_con_event_count--;
@@ -2843,9 +2866,12 @@ _ecore_con_event_server_del_free(void *data EINA_UNUSED,
2843 if (e->server) 2866 if (e->server)
2844 { 2867 {
2845 Ecore_Con_Server_Data *svr = eo_data_scope_get(e->server, ECORE_CON_SERVER_CLASS); 2868 Ecore_Con_Server_Data *svr = eo_data_scope_get(e->server, ECORE_CON_SERVER_CLASS);
2846 svr->event_count = eina_list_remove(svr->event_count, ev); 2869 if (svr)
2847 if (!svr->event_count) 2870 {
2848 _ecore_con_server_free(e->server); 2871 svr->event_count = eina_list_remove(svr->event_count, ev);
2872 if (!svr->event_count)
2873 _ecore_con_server_free(e->server);
2874 }
2849 } 2875 }
2850 ecore_con_event_server_del_free(e); 2876 ecore_con_event_server_del_free(e);
2851 _ecore_con_event_count--; 2877 _ecore_con_event_count--;
@@ -2860,11 +2886,13 @@ _ecore_con_event_server_write_free(void *data EINA_UNUSED,
2860 if (e->server) 2886 if (e->server)
2861 { 2887 {
2862 Ecore_Con_Server_Data *svr = eo_data_scope_get(e->server, ECORE_CON_SERVER_CLASS); 2888 Ecore_Con_Server_Data *svr = eo_data_scope_get(e->server, ECORE_CON_SERVER_CLASS);
2863 svr->event_count = eina_list_remove(svr->event_count, e); 2889 if (svr)
2864 if ((!svr->event_count) && (svr->delete_me)) 2890 {
2865 _ecore_con_server_free(e->server); 2891 svr->event_count = eina_list_remove(svr->event_count, e);
2892 if ((!svr->event_count) && (svr->delete_me))
2893 _ecore_con_server_free(e->server);
2894 }
2866 } 2895 }
2867
2868 ecore_con_event_server_write_free(e); 2896 ecore_con_event_server_write_free(e);
2869 _ecore_con_event_count--; 2897 _ecore_con_event_count--;
2870 if ((!_ecore_con_event_count) && (!_ecore_con_init_count)) 2898 if ((!_ecore_con_event_count) && (!_ecore_con_init_count))
@@ -2881,9 +2909,12 @@ _ecore_con_event_server_data_free(void *data EINA_UNUSED,
2881 if (e->server) 2909 if (e->server)
2882 { 2910 {
2883 Ecore_Con_Server_Data *svr = eo_data_scope_get(e->server, ECORE_CON_SERVER_CLASS); 2911 Ecore_Con_Server_Data *svr = eo_data_scope_get(e->server, ECORE_CON_SERVER_CLASS);
2884 svr->event_count = eina_list_remove(svr->event_count, ev); 2912 if (svr)
2885 if ((!svr->event_count) && (svr->delete_me)) 2913 {
2886 _ecore_con_server_free(e->server); 2914 svr->event_count = eina_list_remove(svr->event_count, ev);
2915 if ((!svr->event_count) && (svr->delete_me))
2916 _ecore_con_server_free(e->server);
2917 }
2887 } 2918 }
2888 2919
2889 free(e->data); 2920 free(e->data);
@@ -2899,9 +2930,12 @@ _ecore_con_event_server_error_free(void *data EINA_UNUSED, Ecore_Con_Event_Serve
2899 if (e->server) 2930 if (e->server)
2900 { 2931 {
2901 Ecore_Con_Server_Data *svr = eo_data_scope_get(e->server, ECORE_CON_SERVER_CLASS); 2932 Ecore_Con_Server_Data *svr = eo_data_scope_get(e->server, ECORE_CON_SERVER_CLASS);
2902 svr->event_count = eina_list_remove(svr->event_count, e); 2933 if (svr)
2903 if ((!svr->event_count) && (svr->delete_me)) 2934 {
2904 _ecore_con_server_free(e->server); 2935 svr->event_count = eina_list_remove(svr->event_count, e);
2936 if ((!svr->event_count) && (svr->delete_me))
2937 _ecore_con_server_free(e->server);
2938 }
2905 } 2939 }
2906 free(e->error); 2940 free(e->error);
2907 ecore_con_event_server_error_free(e); 2941 ecore_con_event_server_error_free(e);
@@ -2919,20 +2953,23 @@ _ecore_con_event_client_error_free(Ecore_Con_Server *obj, Ecore_Con_Event_Client
2919 Ecore_Con_Client_Data *cl = eo_data_scope_get(e->client, ECORE_CON_CLIENT_CLASS); 2953 Ecore_Con_Client_Data *cl = eo_data_scope_get(e->client, ECORE_CON_CLIENT_CLASS);
2920 Eina_Bool svrfreed = EINA_FALSE; 2954 Eina_Bool svrfreed = EINA_FALSE;
2921 2955
2922 if (eina_list_data_find(svr->clients, e->client)) 2956 if ((svr) && (cl))
2923 { 2957 {
2924 cl->event_count = eina_list_remove(cl->event_count, e); 2958 if (eina_list_data_find(svr->clients, e->client))
2925 if ((!cl->event_count) && (cl->delete_me))
2926 { 2959 {
2927 _ecore_con_client_free(e->client); 2960 cl->event_count = eina_list_remove(cl->event_count, e);
2928 svrfreed = EINA_TRUE; 2961 if ((!cl->event_count) && (cl->delete_me))
2962 {
2963 _ecore_con_client_free(e->client);
2964 svrfreed = EINA_TRUE;
2965 }
2966 }
2967 svr->event_count = eina_list_remove(svr->event_count, e);
2968 if (!svrfreed)
2969 {
2970 if ((!svr->event_count) && (svr->delete_me))
2971 _ecore_con_server_free(obj);
2929 } 2972 }
2930 }
2931 svr->event_count = eina_list_remove(svr->event_count, e);
2932 if (!svrfreed)
2933 {
2934 if ((!svr->event_count) && (svr->delete_me))
2935 _ecore_con_server_free(obj);
2936 } 2973 }
2937 } 2974 }
2938 free(e->error); 2975 free(e->error);
@@ -2950,6 +2987,7 @@ _ecore_con_lookup_done(void *data,
2950 Ecore_Con_Lookup *lk; 2987 Ecore_Con_Lookup *lk;
2951 2988
2952 Ecore_Con_Server_Data *svr = eo_data_scope_get(obj, ECORE_CON_SERVER_CLASS); 2989 Ecore_Con_Server_Data *svr = eo_data_scope_get(obj, ECORE_CON_SERVER_CLASS);
2990 if (!svr) return;
2953 lk = svr->data; 2991 lk = svr->data;
2954 2992
2955 if (infos) 2993 if (infos)