summaryrefslogtreecommitdiff
path: root/legacy/ecore
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2006-03-20 05:53:12 +0000
committerCarsten Haitzler <raster@rasterman.com>2006-03-20 05:53:12 +0000
commitb2ecc06e6826d096217c4dca2a33366e7588aa6c (patch)
tree8798646dd0de24949aa24039e35ff9666776a72b /legacy/ecore
parentb1e03e8791238576c57597b2fb6517a503246946 (diff)
defer server and client deletion for con and ipc until all pending events
have been processed. SVN revision: 21434
Diffstat (limited to 'legacy/ecore')
-rw-r--r--legacy/ecore/src/lib/ecore_con/ecore_con.c113
-rw-r--r--legacy/ecore/src/lib/ecore_con/ecore_con_private.h13
-rw-r--r--legacy/ecore/src/lib/ecore_ipc/ecore_ipc.c110
-rw-r--r--legacy/ecore/src/lib/ecore_ipc/ecore_ipc_private.h6
4 files changed, 205 insertions, 37 deletions
diff --git a/legacy/ecore/src/lib/ecore_con/ecore_con.c b/legacy/ecore/src/lib/ecore_con/ecore_con.c
index 1df850a2fd..b845961208 100644
--- a/legacy/ecore/src/lib/ecore_con/ecore_con.c
+++ b/legacy/ecore/src/lib/ecore_con/ecore_con.c
@@ -34,7 +34,11 @@ static int _ecore_con_cl_handler(void *data, Ecore_Fd_Handler *fd_handler);
34static int _ecore_con_svr_cl_handler(void *data, Ecore_Fd_Handler *fd_handler); 34static int _ecore_con_svr_cl_handler(void *data, Ecore_Fd_Handler *fd_handler);
35static void _ecore_con_server_flush(Ecore_Con_Server *svr); 35static void _ecore_con_server_flush(Ecore_Con_Server *svr);
36static void _ecore_con_client_flush(Ecore_Con_Client *cl); 36static void _ecore_con_client_flush(Ecore_Con_Client *cl);
37static void _ecore_con_event_client_add_free(void *data, void *ev);
38static void _ecore_con_event_client_del_free(void *data, void *ev);
37static void _ecore_con_event_client_data_free(void *data, void *ev); 39static void _ecore_con_event_client_data_free(void *data, void *ev);
40static void _ecore_con_event_server_add_free(void *data, void *ev);
41static void _ecore_con_event_server_del_free(void *data, void *ev);
38static void _ecore_con_event_server_data_free(void *data, void *ev); 42static void _ecore_con_event_server_data_free(void *data, void *ev);
39 43
40EAPI int ECORE_CON_EVENT_CLIENT_ADD = 0; 44EAPI int ECORE_CON_EVENT_CLIENT_ADD = 0;
@@ -436,8 +440,10 @@ ecore_con_server_connect(Ecore_Con_Type compl_type,
436 e = calloc(1, sizeof(Ecore_Con_Event_Server_Add)); 440 e = calloc(1, sizeof(Ecore_Con_Event_Server_Add));
437 if (e) 441 if (e)
438 { 442 {
443 svr->event_count++;
439 e->server = svr; 444 e->server = svr;
440 ecore_event_add(ECORE_CON_EVENT_SERVER_ADD, e, NULL, NULL); 445 ecore_event_add(ECORE_CON_EVENT_SERVER_ADD, e,
446 _ecore_con_event_server_add_free, NULL);
441 } 447 }
442 } 448 }
443 } 449 }
@@ -491,10 +497,15 @@ ecore_con_server_del(Ecore_Con_Server *svr)
491 ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, 497 ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER,
492 "ecore_con_server_del"); 498 "ecore_con_server_del");
493 return NULL; 499 return NULL;
494 } 500 }
495 data = svr->data; 501 data = svr->data;
496 _ecore_con_server_free(svr); 502 if (svr->event_count > 0)
497 if (ecore_list_goto(servers, svr)) ecore_list_remove(servers); 503 svr->delete_me = 1;
504 else
505 {
506 _ecore_con_server_free(svr);
507 if (ecore_list_goto(servers, svr)) ecore_list_remove(servers);
508 }
498 return data; 509 return data;
499} 510}
500 511
@@ -700,9 +711,14 @@ ecore_con_client_del(Ecore_Con_Client *cl)
700 return NULL; 711 return NULL;
701 } 712 }
702 data = cl->data; 713 data = cl->data;
703 if (ecore_list_goto(cl->server->clients, cl)) 714 if (cl->event_count > 0)
704 ecore_list_remove(cl->server->clients); 715 cl->delete_me = 1;
705 _ecore_con_client_free(cl); 716 else
717 {
718 if (ecore_list_goto(cl->server->clients, cl))
719 ecore_list_remove(cl->server->clients);
720 _ecore_con_client_free(cl);
721 }
706 return data; 722 return data;
707} 723}
708 724
@@ -842,8 +858,10 @@ _ecore_con_svr_handler(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__)
842 e = calloc(1, sizeof(Ecore_Con_Event_Client_Add)); 858 e = calloc(1, sizeof(Ecore_Con_Event_Client_Add));
843 if (e) 859 if (e)
844 { 860 {
861 cl->event_count++;
845 e->client = cl; 862 e->client = cl;
846 ecore_event_add(ECORE_CON_EVENT_CLIENT_ADD, e, NULL, NULL); 863 ecore_event_add(ECORE_CON_EVENT_CLIENT_ADD, e,
864 _ecore_con_event_client_add_free, NULL);
847 } 865 }
848 } 866 }
849 } 867 }
@@ -888,8 +906,10 @@ kill_server(Ecore_Con_Server *svr)
888 e = calloc(1, sizeof(Ecore_Con_Event_Server_Del)); 906 e = calloc(1, sizeof(Ecore_Con_Event_Server_Del));
889 if (e) 907 if (e)
890 { 908 {
909 svr->event_count++;
891 e->server = svr; 910 e->server = svr;
892 ecore_event_add(ECORE_CON_EVENT_SERVER_DEL, e, NULL, NULL); 911 ecore_event_add(ECORE_CON_EVENT_SERVER_DEL, e,
912 _ecore_con_event_server_del_free, NULL);
893 } 913 }
894 914
895 svr->dead = 1; 915 svr->dead = 1;
@@ -984,8 +1004,10 @@ svr_try_connect_plain(Ecore_Con_Server *svr)
984 e = calloc(1, sizeof(Ecore_Con_Event_Server_Add)); 1004 e = calloc(1, sizeof(Ecore_Con_Event_Server_Add));
985 if (e) 1005 if (e)
986 { 1006 {
1007 svr->event_count++;
987 e->server = svr; 1008 e->server = svr;
988 ecore_event_add(ECORE_CON_EVENT_SERVER_ADD, e, NULL, NULL); 1009 ecore_event_add(ECORE_CON_EVENT_SERVER_ADD, e,
1010 _ecore_con_event_server_add_free, NULL);
989 } 1011 }
990 if (!svr->write_buf) 1012 if (!svr->write_buf)
991 ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ); 1013 ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ);
@@ -1081,11 +1103,13 @@ _ecore_con_cl_handler(void *data, Ecore_Fd_Handler *fd_handler)
1081 e = calloc(1, sizeof(Ecore_Con_Event_Server_Data)); 1103 e = calloc(1, sizeof(Ecore_Con_Event_Server_Data));
1082 if (e) 1104 if (e)
1083 { 1105 {
1106 svr->event_count++;
1084 e->server = svr; 1107 e->server = svr;
1085 e->data = inbuf; 1108 e->data = inbuf;
1086 e->size = inbuf_num; 1109 e->size = inbuf_num;
1087 ecore_event_add(ECORE_CON_EVENT_SERVER_DATA, e, 1110 ecore_event_add(ECORE_CON_EVENT_SERVER_DATA, e,
1088 _ecore_con_event_server_data_free, NULL); 1111 _ecore_con_event_server_data_free,
1112 NULL);
1089 } 1113 }
1090 } 1114 }
1091 if (lost_server) 1115 if (lost_server)
@@ -1150,11 +1174,13 @@ _ecore_con_svr_cl_handler(void *data, Ecore_Fd_Handler *fd_handler)
1150 e = calloc(1, sizeof(Ecore_Con_Event_Client_Data)); 1174 e = calloc(1, sizeof(Ecore_Con_Event_Client_Data));
1151 if (e) 1175 if (e)
1152 { 1176 {
1177 cl->event_count++;
1153 e->client = cl; 1178 e->client = cl;
1154 e->data = inbuf; 1179 e->data = inbuf;
1155 e->size = inbuf_num; 1180 e->size = inbuf_num;
1156 ecore_event_add(ECORE_CON_EVENT_CLIENT_DATA, e, 1181 ecore_event_add(ECORE_CON_EVENT_CLIENT_DATA, e,
1157 _ecore_con_event_client_data_free, NULL); 1182 _ecore_con_event_client_data_free,
1183 NULL);
1158 } 1184 }
1159 } 1185 }
1160 if ((errno == EIO) || (errno == EBADF) || 1186 if ((errno == EIO) || (errno == EBADF) ||
@@ -1167,8 +1193,11 @@ _ecore_con_svr_cl_handler(void *data, Ecore_Fd_Handler *fd_handler)
1167 e = calloc(1, sizeof(Ecore_Con_Event_Client_Del)); 1193 e = calloc(1, sizeof(Ecore_Con_Event_Client_Del));
1168 if (e) 1194 if (e)
1169 { 1195 {
1196 cl->event_count++;
1170 e->client = cl; 1197 e->client = cl;
1171 ecore_event_add(ECORE_CON_EVENT_CLIENT_DEL, e, NULL, NULL); 1198 ecore_event_add(ECORE_CON_EVENT_CLIENT_DEL, e,
1199 _ecore_con_event_client_del_free,
1200 NULL);
1172 } 1201 }
1173 cl->dead = 1; 1202 cl->dead = 1;
1174 ecore_main_fd_handler_del(cl->fd_handler); 1203 ecore_main_fd_handler_del(cl->fd_handler);
@@ -1280,8 +1309,10 @@ _ecore_con_client_flush(Ecore_Con_Client *cl)
1280 e = calloc(1, sizeof(Ecore_Con_Event_Client_Del)); 1309 e = calloc(1, sizeof(Ecore_Con_Event_Client_Del));
1281 if (e) 1310 if (e)
1282 { 1311 {
1312 cl->event_count++;
1283 e->client = cl; 1313 e->client = cl;
1284 ecore_event_add(ECORE_CON_EVENT_CLIENT_DEL, e, NULL, NULL); 1314 ecore_event_add(ECORE_CON_EVENT_CLIENT_DEL, e,
1315 _ecore_con_event_client_del_free, NULL);
1285 } 1316 }
1286 cl->dead = 1; 1317 cl->dead = 1;
1287 ecore_main_fd_handler_del(cl->fd_handler); 1318 ecore_main_fd_handler_del(cl->fd_handler);
@@ -1301,12 +1332,63 @@ _ecore_con_client_flush(Ecore_Con_Client *cl)
1301} 1332}
1302 1333
1303static void 1334static void
1335_ecore_con_event_client_add_free(void *data __UNUSED__, void *ev)
1336{
1337 Ecore_Con_Event_Client_Add *e;
1338
1339 e = ev;
1340 e->client->event_count--;
1341 if ((e->client->event_count == 0) && (e->client->delete_me))
1342 ecore_con_client_del(e->client);
1343 free(e);
1344}
1345
1346static void
1347_ecore_con_event_client_del_free(void *data __UNUSED__, void *ev)
1348{
1349 Ecore_Con_Event_Client_Del *e;
1350
1351 e = ev;
1352 e->client->event_count--;
1353 if ((e->client->event_count == 0) && (e->client->delete_me))
1354 ecore_con_client_del(e->client);
1355 free(e);
1356}
1357
1358static void
1304_ecore_con_event_client_data_free(void *data __UNUSED__, void *ev) 1359_ecore_con_event_client_data_free(void *data __UNUSED__, void *ev)
1305{ 1360{
1306 Ecore_Con_Event_Client_Data *e; 1361 Ecore_Con_Event_Client_Data *e;
1307 1362
1308 e = ev; 1363 e = ev;
1364 e->client->event_count--;
1309 if (e->data) free(e->data); 1365 if (e->data) free(e->data);
1366 if ((e->client->event_count == 0) && (e->client->delete_me))
1367 ecore_con_client_del(e->client);
1368 free(e);
1369}
1370
1371static void
1372_ecore_con_event_server_add_free(void *data __UNUSED__, void *ev)
1373{
1374 Ecore_Con_Event_Server_Add *e;
1375
1376 e = ev;
1377 e->server->event_count--;
1378 if ((e->server->event_count == 0) && (e->server->delete_me))
1379 ecore_con_server_del(e->server);
1380 free(e);
1381}
1382
1383static void
1384_ecore_con_event_server_del_free(void *data __UNUSED__, void *ev)
1385{
1386 Ecore_Con_Event_Server_Del *e;
1387
1388 e = ev;
1389 e->server->event_count--;
1390 if ((e->server->event_count == 0) && (e->server->delete_me))
1391 ecore_con_server_del(e->server);
1310 free(e); 1392 free(e);
1311} 1393}
1312 1394
@@ -1316,6 +1398,9 @@ _ecore_con_event_server_data_free(void *data __UNUSED__, void *ev)
1316 Ecore_Con_Event_Server_Data *e; 1398 Ecore_Con_Event_Server_Data *e;
1317 1399
1318 e = ev; 1400 e = ev;
1401 e->server->event_count--;
1319 if (e->data) free(e->data); 1402 if (e->data) free(e->data);
1403 if ((e->server->event_count == 0) && (e->server->delete_me))
1404 ecore_con_server_del(e->server);
1320 free(e); 1405 free(e);
1321} 1406}
diff --git a/legacy/ecore/src/lib/ecore_con/ecore_con_private.h b/legacy/ecore/src/lib/ecore_con/ecore_con_private.h
index 8df44de53c..95063b8a50 100644
--- a/legacy/ecore/src/lib/ecore_con/ecore_con_private.h
+++ b/legacy/ecore/src/lib/ecore_con/ecore_con_private.h
@@ -44,7 +44,9 @@ struct _Ecore_Con_Client
44 int buf_size; 44 int buf_size;
45 int buf_offset; 45 int buf_offset;
46 unsigned char *buf; 46 unsigned char *buf;
47 int event_count;
47 char dead : 1; 48 char dead : 1;
49 char delete_me : 1;
48}; 50};
49 51
50struct _Ecore_Con_Server 52struct _Ecore_Con_Server
@@ -62,17 +64,18 @@ struct _Ecore_Con_Server
62 int write_buf_size; 64 int write_buf_size;
63 int write_buf_offset; 65 int write_buf_offset;
64 unsigned char *write_buf; 66 unsigned char *write_buf;
65 char dead : 1; 67 int event_count;
66 char created : 1;
67 char connecting : 1;
68 char reject_excess_clients : 1;
69 int client_limit; 68 int client_limit;
70 pid_t ppid; 69 pid_t ppid;
71
72#if USE_OPENSSL 70#if USE_OPENSSL
73 SSL_CTX *ssl_ctx; 71 SSL_CTX *ssl_ctx;
74 SSL *ssl; 72 SSL *ssl;
75#endif 73#endif
74 char dead : 1;
75 char created : 1;
76 char connecting : 1;
77 char reject_excess_clients : 1;
78 char delete_me : 1;
76}; 79};
77 80
78#ifdef HAVE_CURL 81#ifdef HAVE_CURL
diff --git a/legacy/ecore/src/lib/ecore_ipc/ecore_ipc.c b/legacy/ecore/src/lib/ecore_ipc/ecore_ipc.c
index 93f8f7e92e..7a562fcc68 100644
--- a/legacy/ecore/src/lib/ecore_ipc/ecore_ipc.c
+++ b/legacy/ecore/src/lib/ecore_ipc/ecore_ipc.c
@@ -217,7 +217,11 @@ static int _ecore_ipc_event_server_add(void *data, int ev_type, void *ev);
217static int _ecore_ipc_event_server_del(void *data, int ev_type, void *ev); 217static int _ecore_ipc_event_server_del(void *data, int ev_type, void *ev);
218static int _ecore_ipc_event_client_data(void *data, int ev_type, void *ev); 218static int _ecore_ipc_event_client_data(void *data, int ev_type, void *ev);
219static int _ecore_ipc_event_server_data(void *data, int ev_type, void *ev); 219static int _ecore_ipc_event_server_data(void *data, int ev_type, void *ev);
220static void _ecore_ipc_event_client_add_free(void *data, void *ev);
221static void _ecore_ipc_event_client_del_free(void *data, void *ev);
220static void _ecore_ipc_event_client_data_free(void *data, void *ev); 222static void _ecore_ipc_event_client_data_free(void *data, void *ev);
223static void _ecore_ipc_event_server_add_free(void *data, void *ev);
224static void _ecore_ipc_event_server_del_free(void *data, void *ev);
221static void _ecore_ipc_event_server_data_free(void *data, void *ev); 225static void _ecore_ipc_event_server_data_free(void *data, void *ev);
222 226
223EAPI int ECORE_IPC_EVENT_CLIENT_ADD = 0; 227EAPI int ECORE_IPC_EVENT_CLIENT_ADD = 0;
@@ -429,13 +433,18 @@ ecore_ipc_server_del(Ecore_Ipc_Server *svr)
429 "ecore_ipc_server_del"); 433 "ecore_ipc_server_del");
430 return NULL; 434 return NULL;
431 } 435 }
432 ECORE_MAGIC_SET(svr, ECORE_MAGIC_NONE);
433 data = svr->data; 436 data = svr->data;
434 while (svr->clients) ecore_ipc_client_del((Ecore_Ipc_Client *)svr->clients); 437 if (svr->event_count > 0)
435 ecore_con_server_del(svr->server); 438 svr->delete_me = 1;
436 servers = _ecore_list2_remove(servers, svr); 439 else
437 if (svr->buf) free(svr->buf); 440 {
438 free(svr); 441 ECORE_MAGIC_SET(svr, ECORE_MAGIC_NONE);
442 while (svr->clients) ecore_ipc_client_del((Ecore_Ipc_Client *)svr->clients);
443 ecore_con_server_del(svr->server);
444 servers = _ecore_list2_remove(servers, svr);
445 if (svr->buf) free(svr->buf);
446 free(svr);
447 }
439 return data; 448 return data;
440} 449}
441 450
@@ -760,13 +769,18 @@ ecore_ipc_client_del(Ecore_Ipc_Client *cl)
760 "ecore_ipc_client_del"); 769 "ecore_ipc_client_del");
761 return NULL; 770 return NULL;
762 } 771 }
763 ECORE_MAGIC_SET(cl, ECORE_MAGIC_NONE);
764 data = cl->data; 772 data = cl->data;
765 svr = ecore_con_server_data_get(ecore_con_client_server_get(cl->client)); 773 if (cl->event_count > 0)
766 ecore_con_client_del(cl->client); 774 cl->delete_me = 1;
767 svr->clients = _ecore_list2_remove(svr->clients, cl); 775 else
768 if (cl->buf) free(cl->buf); 776 {
769 free(cl); 777 ECORE_MAGIC_SET(cl, ECORE_MAGIC_NONE);
778 svr = ecore_con_server_data_get(ecore_con_client_server_get(cl->client));
779 ecore_con_client_del(cl->client);
780 svr->clients = _ecore_list2_remove(svr->clients, cl);
781 if (cl->buf) free(cl->buf);
782 free(cl);
783 }
770 return data; 784 return data;
771} 785}
772 786
@@ -868,8 +882,10 @@ _ecore_ipc_event_client_add(void *data __UNUSED__, int ev_type __UNUSED__, void
868 e2 = calloc(1, sizeof(Ecore_Ipc_Event_Client_Add)); 882 e2 = calloc(1, sizeof(Ecore_Ipc_Event_Client_Add));
869 if (e2) 883 if (e2)
870 { 884 {
885 cl->event_count++;
871 e2->client = cl; 886 e2->client = cl;
872 ecore_event_add(ECORE_IPC_EVENT_CLIENT_ADD, e2, NULL, NULL); 887 ecore_event_add(ECORE_IPC_EVENT_CLIENT_ADD, e2,
888 _ecore_ipc_event_client_add_free, NULL);
873 } 889 }
874 } 890 }
875 } 891 }
@@ -894,8 +910,10 @@ _ecore_ipc_event_client_del(void *data __UNUSED__, int ev_type __UNUSED__, void
894 e2 = calloc(1, sizeof(Ecore_Ipc_Event_Client_Del)); 910 e2 = calloc(1, sizeof(Ecore_Ipc_Event_Client_Del));
895 if (e2) 911 if (e2)
896 { 912 {
913 cl->event_count++;
897 e2->client = cl; 914 e2->client = cl;
898 ecore_event_add(ECORE_IPC_EVENT_CLIENT_DEL, e2, NULL, NULL); 915 ecore_event_add(ECORE_IPC_EVENT_CLIENT_DEL, e2,
916 _ecore_ipc_event_client_del_free, NULL);
899 } 917 }
900 } 918 }
901 } 919 }
@@ -920,8 +938,10 @@ _ecore_ipc_event_server_add(void *data __UNUSED__, int ev_type __UNUSED__, void
920 e2 = calloc(1, sizeof(Ecore_Ipc_Event_Server_Add)); 938 e2 = calloc(1, sizeof(Ecore_Ipc_Event_Server_Add));
921 if (e2) 939 if (e2)
922 { 940 {
941 svr->event_count++;
923 e2->server = svr; 942 e2->server = svr;
924 ecore_event_add(ECORE_IPC_EVENT_SERVER_ADD, e2, NULL, NULL); 943 ecore_event_add(ECORE_IPC_EVENT_SERVER_ADD, e2,
944 _ecore_ipc_event_server_add_free, NULL);
925 } 945 }
926 } 946 }
927 } 947 }
@@ -946,8 +966,10 @@ _ecore_ipc_event_server_del(void *data __UNUSED__, int ev_type __UNUSED__, void
946 e2 = calloc(1, sizeof(Ecore_Ipc_Event_Server_Del)); 966 e2 = calloc(1, sizeof(Ecore_Ipc_Event_Server_Del));
947 if (e2) 967 if (e2)
948 { 968 {
969 svr->event_count++;
949 e2->server = svr; 970 e2->server = svr;
950 ecore_event_add(ECORE_IPC_EVENT_SERVER_DEL, e2, NULL, NULL); 971 ecore_event_add(ECORE_IPC_EVENT_SERVER_DEL, e2,
972 _ecore_ipc_event_server_del_free, NULL);
951 } 973 }
952 } 974 }
953 } 975 }
@@ -1098,6 +1120,7 @@ _ecore_ipc_event_client_data(void *data __UNUSED__, int ev_type __UNUSED__, void
1098 e2 = calloc(1, sizeof(Ecore_Ipc_Event_Client_Data)); 1120 e2 = calloc(1, sizeof(Ecore_Ipc_Event_Client_Data));
1099 if (e2) 1121 if (e2)
1100 { 1122 {
1123 cl->event_count++;
1101 e2->client = cl; 1124 e2->client = cl;
1102 e2->major = msg.major; 1125 e2->major = msg.major;
1103 e2->minor = msg.minor; 1126 e2->minor = msg.minor;
@@ -1107,7 +1130,8 @@ _ecore_ipc_event_client_data(void *data __UNUSED__, int ev_type __UNUSED__, void
1107 e2->size = msg.size; 1130 e2->size = msg.size;
1108 e2->data = buf; 1131 e2->data = buf;
1109 ecore_event_add(ECORE_IPC_EVENT_CLIENT_DATA, e2, 1132 ecore_event_add(ECORE_IPC_EVENT_CLIENT_DATA, e2,
1110 _ecore_ipc_event_client_data_free, NULL); 1133 _ecore_ipc_event_client_data_free,
1134 NULL);
1111 } 1135 }
1112 } 1136 }
1113 cl->prev.i = msg; 1137 cl->prev.i = msg;
@@ -1276,6 +1300,7 @@ _ecore_ipc_event_server_data(void *data __UNUSED__, int ev_type __UNUSED__, void
1276 e2 = calloc(1, sizeof(Ecore_Ipc_Event_Server_Data)); 1300 e2 = calloc(1, sizeof(Ecore_Ipc_Event_Server_Data));
1277 if (e2) 1301 if (e2)
1278 { 1302 {
1303 svr->event_count++;
1279 e2->server = svr; 1304 e2->server = svr;
1280 e2->major = msg.major; 1305 e2->major = msg.major;
1281 e2->minor = msg.minor; 1306 e2->minor = msg.minor;
@@ -1285,7 +1310,8 @@ _ecore_ipc_event_server_data(void *data __UNUSED__, int ev_type __UNUSED__, void
1285 e2->size = msg.size; 1310 e2->size = msg.size;
1286 e2->data = buf; 1311 e2->data = buf;
1287 ecore_event_add(ECORE_IPC_EVENT_SERVER_DATA, e2, 1312 ecore_event_add(ECORE_IPC_EVENT_SERVER_DATA, e2,
1288 _ecore_ipc_event_server_data_free, NULL); 1313 _ecore_ipc_event_server_data_free,
1314 NULL);
1289 } 1315 }
1290 } 1316 }
1291 svr->prev.i = msg; 1317 svr->prev.i = msg;
@@ -1322,12 +1348,58 @@ _ecore_ipc_event_server_data(void *data __UNUSED__, int ev_type __UNUSED__, void
1322} 1348}
1323 1349
1324static void 1350static void
1351_ecore_ipc_event_client_add_free(void *data __UNUSED__, void *ev)
1352{
1353 Ecore_Ipc_Event_Client_Add *e;
1354
1355 e = ev;
1356 if ((e->client->event_count == 0) && (e->client->delete_me))
1357 ecore_ipc_client_del(e->client);
1358 free(e);
1359}
1360
1361static void
1362_ecore_ipc_event_client_del_free(void *data __UNUSED__, void *ev)
1363{
1364 Ecore_Ipc_Event_Client_Del *e;
1365
1366 e = ev;
1367 if ((e->client->event_count == 0) && (e->client->delete_me))
1368 ecore_ipc_client_del(e->client);
1369 free(e);
1370}
1371
1372static void
1325_ecore_ipc_event_client_data_free(void *data __UNUSED__, void *ev) 1373_ecore_ipc_event_client_data_free(void *data __UNUSED__, void *ev)
1326{ 1374{
1327 Ecore_Ipc_Event_Client_Data *e; 1375 Ecore_Ipc_Event_Client_Data *e;
1328 1376
1329 e = ev; 1377 e = ev;
1330 if (e->data) free(e->data); 1378 if (e->data) free(e->data);
1379 if ((e->client->event_count == 0) && (e->client->delete_me))
1380 ecore_ipc_client_del(e->client);
1381 free(e);
1382}
1383
1384static void
1385_ecore_ipc_event_server_add_free(void *data __UNUSED__, void *ev)
1386{
1387 Ecore_Ipc_Event_Server_Add *e;
1388
1389 e = ev;
1390 if ((e->server->event_count == 0) && (e->server->delete_me))
1391 ecore_ipc_server_del(e->server);
1392 free(e);
1393}
1394
1395static void
1396_ecore_ipc_event_server_del_free(void *data __UNUSED__, void *ev)
1397{
1398 Ecore_Ipc_Event_Server_Add *e;
1399
1400 e = ev;
1401 if ((e->server->event_count == 0) && (e->server->delete_me))
1402 ecore_ipc_server_del(e->server);
1331 free(e); 1403 free(e);
1332} 1404}
1333 1405
@@ -1338,5 +1410,7 @@ _ecore_ipc_event_server_data_free(void *data __UNUSED__, void *ev)
1338 1410
1339 e = ev; 1411 e = ev;
1340 if (e->data) free(e->data); 1412 if (e->data) free(e->data);
1413 if ((e->server->event_count == 0) && (e->server->delete_me))
1414 ecore_ipc_server_del(e->server);
1341 free(e); 1415 free(e);
1342} 1416}
diff --git a/legacy/ecore/src/lib/ecore_ipc/ecore_ipc_private.h b/legacy/ecore/src/lib/ecore_ipc/ecore_ipc_private.h
index 23584c2adc..8b5f59b55c 100644
--- a/legacy/ecore/src/lib/ecore_ipc/ecore_ipc_private.h
+++ b/legacy/ecore/src/lib/ecore_ipc/ecore_ipc_private.h
@@ -48,6 +48,9 @@ struct _Ecore_Ipc_Client
48 struct { 48 struct {
49 Ecore_Ipc_Msg_Head i, o; 49 Ecore_Ipc_Msg_Head i, o;
50 } prev; 50 } prev;
51
52 int event_count;
53 char delete_me : 1;
51}; 54};
52 55
53struct _Ecore_Ipc_Server 56struct _Ecore_Ipc_Server
@@ -64,6 +67,9 @@ struct _Ecore_Ipc_Server
64 struct { 67 struct {
65 Ecore_Ipc_Msg_Head i, o; 68 Ecore_Ipc_Msg_Head i, o;
66 } prev; 69 } prev;
70
71 int event_count;
72 char delete_me : 1;
67}; 73};
68 74
69#endif 75#endif