summaryrefslogtreecommitdiff
path: root/legacy
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2010-12-12 14:41:04 +0000
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>2010-12-12 14:41:04 +0000
commitdd8fe515a3525b18eae8d4a6e7a2e0c8f9499e37 (patch)
tree587b0e1ef2c72cce345de689b99da2b2e18ef802 /legacy
parent8babc062be951b774110468e272fdb688541965f (diff)
fix usage of ecore_con functions to avoid magic failures: SOMEONE WHO KNOWS THIS CODE PLEASE DOUBLE CHECK FAILURE CASE RETURN VALUES
SVN revision: 55512
Diffstat (limited to 'legacy')
-rw-r--r--legacy/ecore/src/lib/ecore_ipc/ecore_ipc.c103
1 files changed, 58 insertions, 45 deletions
diff --git a/legacy/ecore/src/lib/ecore_ipc/ecore_ipc.c b/legacy/ecore/src/lib/ecore_ipc/ecore_ipc.c
index 4024280e8f..8a69b1096e 100644
--- a/legacy/ecore/src/lib/ecore_ipc/ecore_ipc.c
+++ b/legacy/ecore/src/lib/ecore_ipc/ecore_ipc.c
@@ -844,7 +844,8 @@ ecore_ipc_client_server_get(Ecore_Ipc_Client *cl)
844 "ecore_ipc_client_server_get"); 844 "ecore_ipc_client_server_get");
845 return NULL; 845 return NULL;
846 } 846 }
847 return (ecore_con_server_data_get(ecore_con_client_server_get(cl->client))); 847 if (!ecore_con_client_server_get(cl->client)) return NULL;
848 return ecore_con_server_data_get(ecore_con_client_server_get(cl->client));
848} 849}
849 850
850/** 851/**
@@ -871,9 +872,15 @@ ecore_ipc_client_del(Ecore_Ipc_Client *cl)
871 cl->delete_me = 1; 872 cl->delete_me = 1;
872 if (cl->event_count == 0) 873 if (cl->event_count == 0)
873 { 874 {
874 svr = ecore_con_server_data_get(ecore_con_client_server_get(cl->client)); 875 Ecore_Con_Server *s;
876
875 ecore_con_client_del(cl->client); 877 ecore_con_client_del(cl->client);
876 svr->clients = eina_list_remove(svr->clients, cl); 878 s = ecore_con_client_server_get(cl->client);
879 if (s)
880 {
881 svr = ecore_con_server_data_get(s);
882 svr->clients = eina_list_remove(svr->clients, cl);
883 }
877 if (cl->buf) free(cl->buf); 884 if (cl->buf) free(cl->buf);
878 ECORE_MAGIC_SET(cl, ECORE_MAGIC_NONE); 885 ECORE_MAGIC_SET(cl, ECORE_MAGIC_NONE);
879 free(cl); 886 free(cl);
@@ -1011,17 +1018,21 @@ static Eina_Bool
1011_ecore_ipc_event_client_add(void *data __UNUSED__, int ev_type __UNUSED__, void *ev) 1018_ecore_ipc_event_client_add(void *data __UNUSED__, int ev_type __UNUSED__, void *ev)
1012{ 1019{
1013 Ecore_Con_Event_Client_Add *e; 1020 Ecore_Con_Event_Client_Add *e;
1021 Ecore_Con_Server *s;
1022 Ecore_Ipc_Server *svr;
1014 1023
1015 e = ev; 1024 e = ev;
1016 if (!eina_list_data_find(servers, ecore_con_server_data_get(ecore_con_client_server_get(e->client)))) return ECORE_CALLBACK_RENEW; 1025 s = ecore_con_client_server_get(e->client);
1026 if (!s) return ECORE_CALLBACK_RENEW;
1027 svr = ecore_con_server_data_get(s);
1028 if (!svr) return ECORE_CALLBACK_RENEW;
1029 if (!eina_list_data_find(servers, svr)) return ECORE_CALLBACK_RENEW;
1017 /* handling code here */ 1030 /* handling code here */
1018 { 1031 {
1019 Ecore_Ipc_Client *cl; 1032 Ecore_Ipc_Client *cl;
1020 Ecore_Ipc_Server *svr;
1021 1033
1022 cl = calloc(1, sizeof(Ecore_Ipc_Client)); 1034 cl = calloc(1, sizeof(Ecore_Ipc_Client));
1023 if (!cl) return ECORE_CALLBACK_CANCEL; 1035 if (!cl) return ECORE_CALLBACK_CANCEL;
1024 svr = ecore_con_server_data_get(ecore_con_client_server_get(e->client));
1025 ECORE_MAGIC_SET(cl, ECORE_MAGIC_IPC_CLIENT); 1036 ECORE_MAGIC_SET(cl, ECORE_MAGIC_IPC_CLIENT);
1026 cl->client = e->client; 1037 cl->client = e->client;
1027 cl->max_buf_size = 32 * 1024; 1038 cl->max_buf_size = 32 * 1024;
@@ -1049,9 +1060,15 @@ static Eina_Bool
1049_ecore_ipc_event_client_del(void *data __UNUSED__, int ev_type __UNUSED__, void *ev) 1060_ecore_ipc_event_client_del(void *data __UNUSED__, int ev_type __UNUSED__, void *ev)
1050{ 1061{
1051 Ecore_Con_Event_Client_Del *e; 1062 Ecore_Con_Event_Client_Del *e;
1063 Ecore_Con_Server *s;
1064 Ecore_Ipc_Server *svr;
1052 1065
1053 e = ev; 1066 e = ev;
1054 if (!eina_list_data_find(servers, ecore_con_server_data_get(ecore_con_client_server_get(e->client)))) return ECORE_CALLBACK_RENEW; 1067 s = ecore_con_client_server_get(e->client);
1068 if (!s) return ECORE_CALLBACK_RENEW;
1069 svr = ecore_con_server_data_get(s);
1070 if (!svr) return ECORE_CALLBACK_RENEW;
1071 if (!eina_list_data_find(servers, svr)) return ECORE_CALLBACK_RENEW;
1055 /* handling code here */ 1072 /* handling code here */
1056 { 1073 {
1057 Ecore_Ipc_Client *cl; 1074 Ecore_Ipc_Client *cl;
@@ -1059,9 +1076,7 @@ _ecore_ipc_event_client_del(void *data __UNUSED__, int ev_type __UNUSED__, void
1059 cl = ecore_con_client_data_get(e->client); 1076 cl = ecore_con_client_data_get(e->client);
1060 { 1077 {
1061 Ecore_Ipc_Event_Client_Del *e2; 1078 Ecore_Ipc_Event_Client_Del *e2;
1062 Ecore_Ipc_Server *svr;
1063 1079
1064 svr = ecore_con_server_data_get(ecore_con_client_server_get(e->client));
1065 svr->client_list = eina_list_remove(svr->client_list, cl); 1080 svr->client_list = eina_list_remove(svr->client_list, cl);
1066 if (!cl->delete_me) 1081 if (!cl->delete_me)
1067 { 1082 {
@@ -1083,26 +1098,23 @@ static Eina_Bool
1083_ecore_ipc_event_server_add(void *data __UNUSED__, int ev_type __UNUSED__, void *ev) 1098_ecore_ipc_event_server_add(void *data __UNUSED__, int ev_type __UNUSED__, void *ev)
1084{ 1099{
1085 Ecore_Con_Event_Server_Add *e; 1100 Ecore_Con_Event_Server_Add *e;
1101 Ecore_Ipc_Server *svr;
1086 1102
1087 e = ev; 1103 e = ev;
1088 if (!eina_list_data_find(servers, ecore_con_server_data_get(e->server))) return ECORE_CALLBACK_RENEW; 1104 svr = ecore_con_server_data_get(e->server);
1105 if (!eina_list_data_find(servers, svr)) return ECORE_CALLBACK_RENEW;
1089 /* handling code here */ 1106 /* handling code here */
1107 if (!svr->delete_me)
1090 { 1108 {
1091 Ecore_Ipc_Server *svr; 1109 Ecore_Ipc_Event_Server_Add *e2;
1092 1110
1093 svr = ecore_con_server_data_get(e->server); 1111 e2 = calloc(1, sizeof(Ecore_Ipc_Event_Server_Add));
1094 if (!svr->delete_me) 1112 if (e2)
1095 { 1113 {
1096 Ecore_Ipc_Event_Server_Add *e2; 1114 svr->event_count++;
1097 1115 e2->server = svr;
1098 e2 = calloc(1, sizeof(Ecore_Ipc_Event_Server_Add)); 1116 ecore_event_add(ECORE_IPC_EVENT_SERVER_ADD, e2,
1099 if (e2) 1117 _ecore_ipc_event_server_add_free, NULL);
1100 {
1101 svr->event_count++;
1102 e2->server = svr;
1103 ecore_event_add(ECORE_IPC_EVENT_SERVER_ADD, e2,
1104 _ecore_ipc_event_server_add_free, NULL);
1105 }
1106 } 1118 }
1107 } 1119 }
1108 return ECORE_CALLBACK_CANCEL; 1120 return ECORE_CALLBACK_CANCEL;
@@ -1112,26 +1124,23 @@ static Eina_Bool
1112_ecore_ipc_event_server_del(void *data __UNUSED__, int ev_type __UNUSED__, void *ev) 1124_ecore_ipc_event_server_del(void *data __UNUSED__, int ev_type __UNUSED__, void *ev)
1113{ 1125{
1114 Ecore_Con_Event_Server_Del *e; 1126 Ecore_Con_Event_Server_Del *e;
1127 Ecore_Ipc_Server *svr;
1115 1128
1116 e = ev; 1129 e = ev;
1117 if (!eina_list_data_find(servers, ecore_con_server_data_get(e->server))) return ECORE_CALLBACK_RENEW; 1130 svr = ecore_con_server_data_get(e->server);
1131 if (!eina_list_data_find(servers, svr)) return ECORE_CALLBACK_RENEW;
1118 /* handling code here */ 1132 /* handling code here */
1133 if (!svr->delete_me)
1119 { 1134 {
1120 Ecore_Ipc_Server *svr; 1135 Ecore_Ipc_Event_Server_Del *e2;
1121 1136
1122 svr = ecore_con_server_data_get(e->server); 1137 e2 = calloc(1, sizeof(Ecore_Ipc_Event_Server_Del));
1123 if (!svr->delete_me) 1138 if (e2)
1124 { 1139 {
1125 Ecore_Ipc_Event_Server_Del *e2; 1140 svr->event_count++;
1126 1141 e2->server = svr;
1127 e2 = calloc(1, sizeof(Ecore_Ipc_Event_Server_Del)); 1142 ecore_event_add(ECORE_IPC_EVENT_SERVER_DEL, e2,
1128 if (e2) 1143 _ecore_ipc_event_server_del_free, NULL);
1129 {
1130 svr->event_count++;
1131 e2->server = svr;
1132 ecore_event_add(ECORE_IPC_EVENT_SERVER_DEL, e2,
1133 _ecore_ipc_event_server_del_free, NULL);
1134 }
1135 } 1144 }
1136 } 1145 }
1137 return ECORE_CALLBACK_CANCEL; 1146 return ECORE_CALLBACK_CANCEL;
@@ -1182,17 +1191,19 @@ static Eina_Bool
1182_ecore_ipc_event_client_data(void *data __UNUSED__, int ev_type __UNUSED__, void *ev) 1191_ecore_ipc_event_client_data(void *data __UNUSED__, int ev_type __UNUSED__, void *ev)
1183{ 1192{
1184 Ecore_Con_Event_Client_Data *e; 1193 Ecore_Con_Event_Client_Data *e;
1194 Ecore_Con_Server *svr;
1195 Ecore_Ipc_Client *cl;
1185 1196
1186 e = ev; 1197 e = ev;
1187 if (!eina_list_data_find(servers, ecore_con_server_data_get(ecore_con_client_server_get(e->client)))) return ECORE_CALLBACK_RENEW; 1198 svr = ecore_con_client_server_get(e->client);
1199 cl = ecore_con_server_data_get(svr);
1200 if (!eina_list_data_find(servers, cl)) return ECORE_CALLBACK_RENEW;
1188 /* handling code here */ 1201 /* handling code here */
1189 { 1202 {
1190 Ecore_Ipc_Client *cl;
1191 Ecore_Ipc_Msg_Head msg; 1203 Ecore_Ipc_Msg_Head msg;
1192 int offset = 0; 1204 int offset = 0;
1193 unsigned char *buf; 1205 unsigned char *buf;
1194 1206
1195 cl = ecore_con_client_data_get(e->client);
1196 1207
1197 if (!cl->buf) 1208 if (!cl->buf)
1198 { 1209 {
@@ -1254,10 +1265,13 @@ _ecore_ipc_event_client_data(void *data __UNUSED__, int ev_type __UNUSED__, void
1254 { 1265 {
1255 Ecore_Ipc_Event_Client_Data *e2; 1266 Ecore_Ipc_Event_Client_Data *e2;
1256 Ecore_Ipc_Server *svr; 1267 Ecore_Ipc_Server *svr;
1268 Ecore_Con_Server *sv;
1257 int max, max2; 1269 int max, max2;
1258 1270
1259 buf = NULL; 1271 buf = NULL;
1260 svr = ecore_con_server_data_get(ecore_con_client_server_get(cl->client)); 1272 sv = ecore_con_client_server_get(cl->client);
1273 if (!sv) return ECORE_CALLBACK_CANCEL;
1274 svr = ecore_con_server_data_get(sv);
1261 max = svr->max_buf_size; 1275 max = svr->max_buf_size;
1262 max2 = cl->max_buf_size; 1276 max2 = cl->max_buf_size;
1263 if ((max >= 0) && (max2 >= 0)) 1277 if ((max >= 0) && (max2 >= 0))
@@ -1374,18 +1388,17 @@ static Eina_Bool
1374_ecore_ipc_event_server_data(void *data __UNUSED__, int ev_type __UNUSED__, void *ev) 1388_ecore_ipc_event_server_data(void *data __UNUSED__, int ev_type __UNUSED__, void *ev)
1375{ 1389{
1376 Ecore_Con_Event_Server_Data *e; 1390 Ecore_Con_Event_Server_Data *e;
1391 Ecore_Ipc_Server *svr;
1377 1392
1378 e = ev; 1393 e = ev;
1379 if (!eina_list_data_find(servers, ecore_con_server_data_get(e->server))) return ECORE_CALLBACK_RENEW; 1394 svr = ecore_con_server_data_get(e->server);
1395 if (!eina_list_data_find(servers, svr)) return ECORE_CALLBACK_RENEW;
1380 /* handling code here */ 1396 /* handling code here */
1381 { 1397 {
1382 Ecore_Ipc_Server *svr;
1383 Ecore_Ipc_Msg_Head msg; 1398 Ecore_Ipc_Msg_Head msg;
1384 int offset = 0; 1399 int offset = 0;
1385 unsigned char *buf; 1400 unsigned char *buf;
1386 1401
1387 svr = ecore_con_server_data_get(e->server);
1388
1389 if (!svr->buf) 1402 if (!svr->buf)
1390 { 1403 {
1391 svr->buf_size = e->size; 1404 svr->buf_size = e->size;