summaryrefslogtreecommitdiff
path: root/src/lib/ecore_ipc
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-11-23 22:35:48 -0200
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-11-23 22:35:48 -0200
commit9805f4ec36cf329159a974737d7f37c6204ee671 (patch)
tree866198fd4a81d58754230839d5ea9b639d692266 /src/lib/ecore_ipc
parent400f3932d9a5adb3bc6c360368793a855d5228d8 (diff)
ecore_ipc: isolate legacy within ifdefs.
Compile out the legacy code when running on platforms that support Efl.Net.Dialer.Unix and Efl.Net.Server.Unix.
Diffstat (limited to 'src/lib/ecore_ipc')
-rw-r--r--src/lib/ecore_ipc/ecore_ipc.c78
-rw-r--r--src/lib/ecore_ipc/ecore_ipc_private.h7
2 files changed, 75 insertions, 10 deletions
diff --git a/src/lib/ecore_ipc/ecore_ipc.c b/src/lib/ecore_ipc/ecore_ipc.c
index 15f8edd1a2..e227251467 100644
--- a/src/lib/ecore_ipc/ecore_ipc.c
+++ b/src/lib/ecore_ipc/ecore_ipc.c
@@ -199,12 +199,16 @@ _ecore_ipc_ddlt_int(int in, int prev, int mode)
199 return 0; 199 return 0;
200} 200}
201 201
202/* EFL_NET_SERVER_UNIX_CLASS and EFL_NET_DIALER_UNIX_CLASS should be defined at the same time, we're only checking for EFL_NET_SERVER_UNIX_CLASS in shared blocks */
203#ifndef EFL_NET_SERVER_UNIX_CLASS
202static Eina_Bool _ecore_ipc_event_client_add(void *data, int ev_type, void *ev); 204static Eina_Bool _ecore_ipc_event_client_add(void *data, int ev_type, void *ev);
203static Eina_Bool _ecore_ipc_event_client_del(void *data, int ev_type, void *ev); 205static Eina_Bool _ecore_ipc_event_client_del(void *data, int ev_type, void *ev);
204static Eina_Bool _ecore_ipc_event_server_add(void *data, int ev_type, void *ev); 206static Eina_Bool _ecore_ipc_event_server_add(void *data, int ev_type, void *ev);
205static Eina_Bool _ecore_ipc_event_server_del(void *data, int ev_type, void *ev); 207static Eina_Bool _ecore_ipc_event_server_del(void *data, int ev_type, void *ev);
206static Eina_Bool _ecore_ipc_event_client_data(void *data, int ev_type, void *ev); 208static Eina_Bool _ecore_ipc_event_client_data(void *data, int ev_type, void *ev);
207static Eina_Bool _ecore_ipc_event_server_data(void *data, int ev_type, void *ev); 209static Eina_Bool _ecore_ipc_event_server_data(void *data, int ev_type, void *ev);
210#endif
211
208static void _ecore_ipc_event_client_add_free(void *data, void *ev); 212static void _ecore_ipc_event_client_add_free(void *data, void *ev);
209static void _ecore_ipc_event_client_del_free(void *data, void *ev); 213static void _ecore_ipc_event_client_del_free(void *data, void *ev);
210static void _ecore_ipc_event_client_data_free(void *data, void *ev); 214static void _ecore_ipc_event_client_data_free(void *data, void *ev);
@@ -221,7 +225,10 @@ EAPI int ECORE_IPC_EVENT_SERVER_DATA = 0;
221 225
222static int _ecore_ipc_init_count = 0; 226static int _ecore_ipc_init_count = 0;
223static Eina_List *servers = NULL; 227static Eina_List *servers = NULL;
228
229#ifndef EFL_NET_SERVER_UNIX_CLASS
224static Ecore_Event_Handler *handler[6]; 230static Ecore_Event_Handler *handler[6];
231#endif
225 232
226static void 233static void
227ecore_ipc_post_event_server_add(Ecore_Ipc_Server *svr) 234ecore_ipc_post_event_server_add(Ecore_Ipc_Server *svr)
@@ -306,7 +313,9 @@ ecore_ipc_client_add(Ecore_Ipc_Server *svr)
306EAPI int 313EAPI int
307ecore_ipc_init(void) 314ecore_ipc_init(void)
308{ 315{
316#ifndef EFL_NET_SERVER_UNIX_CLASS
309 int i = 0; 317 int i = 0;
318#endif
310 319
311 if (++_ecore_ipc_init_count != 1) 320 if (++_ecore_ipc_init_count != 1)
312 return _ecore_ipc_init_count; 321 return _ecore_ipc_init_count;
@@ -327,6 +336,7 @@ ecore_ipc_init(void)
327 ECORE_IPC_EVENT_CLIENT_DATA = ecore_event_type_new(); 336 ECORE_IPC_EVENT_CLIENT_DATA = ecore_event_type_new();
328 ECORE_IPC_EVENT_SERVER_DATA = ecore_event_type_new(); 337 ECORE_IPC_EVENT_SERVER_DATA = ecore_event_type_new();
329 338
339#ifndef EFL_NET_SERVER_UNIX_CLASS
330 handler[i++] = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, 340 handler[i++] = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD,
331 _ecore_ipc_event_client_add, NULL); 341 _ecore_ipc_event_client_add, NULL);
332 handler[i++] = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, 342 handler[i++] = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL,
@@ -339,13 +349,16 @@ ecore_ipc_init(void)
339 _ecore_ipc_event_client_data, NULL); 349 _ecore_ipc_event_client_data, NULL);
340 handler[i] = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, 350 handler[i] = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA,
341 _ecore_ipc_event_server_data, NULL); 351 _ecore_ipc_event_server_data, NULL);
352#endif
342 return _ecore_ipc_init_count; 353 return _ecore_ipc_init_count;
343} 354}
344 355
345EAPI int 356EAPI int
346ecore_ipc_shutdown(void) 357ecore_ipc_shutdown(void)
347{ 358{
359#ifndef EFL_NET_SERVER_UNIX_CLASS
348 int i; 360 int i;
361#endif
349 362
350 if (--_ecore_ipc_init_count != 0) 363 if (--_ecore_ipc_init_count != 0)
351 return _ecore_ipc_init_count; 364 return _ecore_ipc_init_count;
@@ -355,8 +368,10 @@ ecore_ipc_shutdown(void)
355 EINA_LIST_FOREACH_SAFE(servers, l, l2, svr) 368 EINA_LIST_FOREACH_SAFE(servers, l, l2, svr)
356 ecore_ipc_server_del(svr); 369 ecore_ipc_server_del(svr);
357 370
371#ifndef EFL_NET_SERVER_UNIX_CLASS
358 for (i = 0; i < 6; i++) 372 for (i = 0; i < 6; i++)
359 ecore_event_handler_del(handler[i]); 373 ecore_event_handler_del(handler[i]);
374#endif
360 375
361 ecore_con_shutdown(); 376 ecore_con_shutdown();
362 eina_log_domain_unregister(_ecore_ipc_log_dom); 377 eina_log_domain_unregister(_ecore_ipc_log_dom);
@@ -384,7 +399,7 @@ EFL_CALLBACKS_ARRAY_DEFINE(_ecore_ipc_server_cbs,
384 399
385#ifndef EFL_NET_SERVER_UNIX_CLASS 400#ifndef EFL_NET_SERVER_UNIX_CLASS
386static Ecore_Ipc_Server * 401static Ecore_Ipc_Server *
387ecore_ipc_server_add_legacy(Ecore_Ipc_Type compl_type, char *name, int port, const void *data) 402ecore_ipc_server_add_legacy(Ecore_Ipc_Type compl_type, const char *name, int port, const void *data)
388{ 403{
389 Ecore_Ipc_Server *svr; 404 Ecore_Ipc_Server *svr;
390 Ecore_Ipc_Type type; 405 Ecore_Ipc_Type type;
@@ -915,7 +930,9 @@ ecore_ipc_server_del(Ecore_Ipc_Server *svr)
915 930
916 if (svr->dialer.dialer) _ecore_ipc_dialer_del(svr); 931 if (svr->dialer.dialer) _ecore_ipc_dialer_del(svr);
917 if (svr->server) _ecore_ipc_server_del(svr); 932 if (svr->server) _ecore_ipc_server_del(svr);
933#ifndef EFL_NET_SERVER_UNIX_CLASS
918 if (svr->legacy_server) ecore_con_server_del(svr->legacy_server); 934 if (svr->legacy_server) ecore_con_server_del(svr->legacy_server);
935#endif
919 servers = eina_list_remove(servers, svr); 936 servers = eina_list_remove(servers, svr);
920 937
921 if (svr->buf) free(svr->buf); 938 if (svr->buf) free(svr->buf);
@@ -952,9 +969,13 @@ ecore_ipc_server_connected_get(Ecore_Ipc_Server *svr)
952 if (svr->dialer.dialer) 969 if (svr->dialer.dialer)
953 return efl_net_dialer_connected_get(svr->dialer.dialer); 970 return efl_net_dialer_connected_get(svr->dialer.dialer);
954 else if (svr->server) return EINA_TRUE; 971 else if (svr->server) return EINA_TRUE;
972#ifndef EFL_NET_SERVER_UNIX_CLASS
955 else if (!svr->legacy_server) return EINA_FALSE; 973 else if (!svr->legacy_server) return EINA_FALSE;
956 974
957 return ecore_con_server_connected_get(svr->legacy_server); 975 return ecore_con_server_connected_get(svr->legacy_server);
976#else
977 return EINA_FALSE;
978#endif
958} 979}
959 980
960EAPI Eina_List * 981EAPI Eina_List *
@@ -1006,7 +1027,6 @@ EAPI int
1006ecore_ipc_server_send(Ecore_Ipc_Server *svr, int major, int minor, int ref, int ref_to, int response, const void *data, int size) 1027ecore_ipc_server_send(Ecore_Ipc_Server *svr, int major, int minor, int ref, int ref_to, int response, const void *data, int size)
1007{ 1028{
1008 Ecore_Ipc_Msg_Head msg; 1029 Ecore_Ipc_Msg_Head msg;
1009 int ret;
1010 int *head, md = 0, d, s; 1030 int *head, md = 0, d, s;
1011 unsigned char dat[sizeof(Ecore_Ipc_Msg_Head)]; 1031 unsigned char dat[sizeof(Ecore_Ipc_Msg_Head)];
1012 1032
@@ -1084,11 +1104,19 @@ ecore_ipc_server_send(Ecore_Ipc_Server *svr, int major, int minor, int ref, int
1084 ERR("Send data to clients, not the server handle"); 1104 ERR("Send data to clients, not the server handle");
1085 return 0; 1105 return 0;
1086 } 1106 }
1107#ifndef EFL_NET_SERVER_UNIX_CLASS
1087 else if (!svr->legacy_server) return 0; 1108 else if (!svr->legacy_server) return 0;
1088 1109
1089 ret = ecore_con_server_send(svr->legacy_server, dat, s); 1110 {
1090 if (size > 0) ret += ecore_con_server_send(svr->legacy_server, data, size); 1111 int ret;
1091 return ret; 1112
1113 ret = ecore_con_server_send(svr->legacy_server, dat, s);
1114 if (size > 0) ret += ecore_con_server_send(svr->legacy_server, data, size);
1115 return ret;
1116 }
1117#else
1118 return 0;
1119#endif
1092} 1120}
1093 1121
1094EAPI void 1122EAPI void
@@ -1105,8 +1133,10 @@ ecore_ipc_server_client_limit_set(Ecore_Ipc_Server *svr, int client_limit, char
1105 efl_net_server_clients_limit_set(svr->server, client_limit, reject_excess_clients); 1133 efl_net_server_clients_limit_set(svr->server, client_limit, reject_excess_clients);
1106 return; 1134 return;
1107 } 1135 }
1136#ifndef EFL_NET_SERVER_UNIX_CLASS
1108 else if (!svr->legacy_server) return; 1137 else if (!svr->legacy_server) return;
1109 ecore_con_server_client_limit_set(svr->legacy_server, client_limit, reject_excess_clients); 1138 ecore_con_server_client_limit_set(svr->legacy_server, client_limit, reject_excess_clients);
1139#endif
1110} 1140}
1111 1141
1112EAPI void 1142EAPI void
@@ -1159,9 +1189,13 @@ ecore_ipc_server_ip_get(Ecore_Ipc_Server *svr)
1159 /* original IPC just returned IP for remote connections */ 1189 /* original IPC just returned IP for remote connections */
1160 return NULL; 1190 return NULL;
1161 } 1191 }
1192#ifndef EFL_NET_SERVER_UNIX_CLASS
1162 else if (!svr->legacy_server) return NULL; 1193 else if (!svr->legacy_server) return NULL;
1163 1194
1164 return ecore_con_server_ip_get(svr->legacy_server); 1195 return ecore_con_server_ip_get(svr->legacy_server);
1196#else
1197 return NULL;
1198#endif
1165} 1199}
1166 1200
1167EAPI void 1201EAPI void
@@ -1184,9 +1218,11 @@ ecore_ipc_server_flush(Ecore_Ipc_Server *svr)
1184 ERR("Flush clients, not the server handle"); 1218 ERR("Flush clients, not the server handle");
1185 return; 1219 return;
1186 } 1220 }
1221#ifndef EFL_NET_SERVER_UNIX_CLASS
1187 else if (!svr->legacy_server) return; 1222 else if (!svr->legacy_server) return;
1188 1223
1189 ecore_con_server_flush(svr->legacy_server); 1224 ecore_con_server_flush(svr->legacy_server);
1225#endif
1190} 1226}
1191 1227
1192#define CLENC(_member) \ 1228#define CLENC(_member) \
@@ -1226,7 +1262,6 @@ EAPI int
1226ecore_ipc_client_send(Ecore_Ipc_Client *cl, int major, int minor, int ref, int ref_to, int response, const void *data, int size) 1262ecore_ipc_client_send(Ecore_Ipc_Client *cl, int major, int minor, int ref, int ref_to, int response, const void *data, int size)
1227{ 1263{
1228 Ecore_Ipc_Msg_Head msg; 1264 Ecore_Ipc_Msg_Head msg;
1229 int ret;
1230 int *head, md = 0, d, s; 1265 int *head, md = 0, d, s;
1231 unsigned char dat[sizeof(Ecore_Ipc_Msg_Head)]; 1266 unsigned char dat[sizeof(Ecore_Ipc_Msg_Head)];
1232 1267
@@ -1238,8 +1273,10 @@ ecore_ipc_client_send(Ecore_Ipc_Client *cl, int major, int minor, int ref, int r
1238 } 1273 }
1239 if (cl->socket.socket) 1274 if (cl->socket.socket)
1240 EINA_SAFETY_ON_TRUE_RETURN_VAL(efl_io_closer_closed_get(cl->socket.socket), 0); 1275 EINA_SAFETY_ON_TRUE_RETURN_VAL(efl_io_closer_closed_get(cl->socket.socket), 0);
1276#ifndef EFL_NET_SERVER_UNIX_CLASS
1241 else if (cl->client) 1277 else if (cl->client)
1242 EINA_SAFETY_ON_TRUE_RETURN_VAL(!ecore_con_client_connected_get(cl->client), 0); 1278 EINA_SAFETY_ON_TRUE_RETURN_VAL(!ecore_con_client_connected_get(cl->client), 0);
1279#endif
1243 else 1280 else
1244 { 1281 {
1245 ERR("client %p is not connected", cl); 1282 ERR("client %p is not connected", cl);
@@ -1309,11 +1346,19 @@ ecore_ipc_client_send(Ecore_Ipc_Client *cl, int major, int minor, int ref, int r
1309 1346
1310 return s + size; 1347 return s + size;
1311 } 1348 }
1349#ifndef EFL_NET_SERVER_UNIX_CLASS
1312 else if (!cl->client) return 0; 1350 else if (!cl->client) return 0;
1313 1351
1314 ret = ecore_con_client_send(cl->client, dat, s); 1352 {
1315 if (size > 0) ret += ecore_con_client_send(cl->client, data, size); 1353 int ret;
1316 return ret; 1354
1355 ret = ecore_con_client_send(cl->client, dat, s);
1356 if (size > 0) ret += ecore_con_client_send(cl->client, data, size);
1357 return ret;
1358 }
1359#else
1360 return 0;
1361#endif
1317} 1362}
1318 1363
1319EAPI Ecore_Ipc_Server * 1364EAPI Ecore_Ipc_Server *
@@ -1482,7 +1527,9 @@ ecore_ipc_client_del(Ecore_Ipc_Client *cl)
1482 { 1527 {
1483 svr = cl->svr; 1528 svr = cl->svr;
1484 if (cl->socket.socket) _ecore_ipc_client_socket_del(cl); 1529 if (cl->socket.socket) _ecore_ipc_client_socket_del(cl);
1530#ifndef EFL_NET_SERVER_UNIX_CLASS
1485 if (cl->client) ecore_con_client_del(cl->client); 1531 if (cl->client) ecore_con_client_del(cl->client);
1532#endif
1486 if (ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_IPC_SERVER)) 1533 if (ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_IPC_SERVER))
1487 svr->clients = eina_list_remove(svr->clients, cl); 1534 svr->clients = eina_list_remove(svr->clients, cl);
1488 if (cl->buf) free(cl->buf); 1535 if (cl->buf) free(cl->buf);
@@ -1559,9 +1606,13 @@ ecore_ipc_client_ip_get(Ecore_Ipc_Client *cl)
1559 */ 1606 */
1560 return "0.0.0.0"; 1607 return "0.0.0.0";
1561 } 1608 }
1609#ifndef EFL_NET_SERVER_UNIX_CLASS
1562 else if (!cl->client) return NULL; 1610 else if (!cl->client) return NULL;
1563 1611
1564 return ecore_con_client_ip_get(cl->client); 1612 return ecore_con_client_ip_get(cl->client);
1613#else
1614 return NULL;
1615#endif
1565} 1616}
1566 1617
1567EAPI void 1618EAPI void
@@ -1579,9 +1630,11 @@ ecore_ipc_client_flush(Ecore_Ipc_Client *cl)
1579 efl_io_copier_flush(cl->socket.send_copier); 1630 efl_io_copier_flush(cl->socket.send_copier);
1580 return; 1631 return;
1581 } 1632 }
1633#ifndef EFL_NET_SERVER_UNIX_CLASS
1582 else if (!cl->client) return; 1634 else if (!cl->client) return;
1583 1635
1584 ecore_con_client_flush(cl->client); 1636 ecore_con_client_flush(cl->client);
1637#endif
1585} 1638}
1586 1639
1587EAPI int 1640EAPI int
@@ -1590,7 +1643,7 @@ ecore_ipc_ssl_available_get(void)
1590 return ecore_con_ssl_available_get(); 1643 return ecore_con_ssl_available_get();
1591} 1644}
1592 1645
1593 1646#ifndef EFL_NET_SERVER_UNIX_CLASS
1594static Eina_Bool 1647static Eina_Bool
1595_ecore_ipc_event_client_add(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev) 1648_ecore_ipc_event_client_add(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev)
1596{ 1649{
@@ -1672,6 +1725,7 @@ _ecore_ipc_event_server_del(void *data EINA_UNUSED, int ev_type EINA_UNUSED, voi
1672 } 1725 }
1673 return ECORE_CALLBACK_CANCEL; 1726 return ECORE_CALLBACK_CANCEL;
1674} 1727}
1728#endif
1675 1729
1676#define CLSZ(_n) \ 1730#define CLSZ(_n) \
1677 md = ((head >> (4 * _n)) & 0xf); \ 1731 md = ((head >> (4 * _n)) & 0xf); \
@@ -1865,6 +1919,7 @@ ecore_ipc_client_data_process(Ecore_Ipc_Client *cl, void *data, int size, Eina_B
1865 return ECORE_CALLBACK_CANCEL; 1919 return ECORE_CALLBACK_CANCEL;
1866} 1920}
1867 1921
1922#ifndef EFL_NET_SERVER_UNIX_CLASS
1868static Eina_Bool 1923static Eina_Bool
1869_ecore_ipc_event_client_data(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev) 1924_ecore_ipc_event_client_data(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev)
1870{ 1925{
@@ -1890,6 +1945,7 @@ _ecore_ipc_event_client_data(void *data EINA_UNUSED, int ev_type EINA_UNUSED, vo
1890 } 1945 }
1891 return ECORE_CALLBACK_CANCEL; 1946 return ECORE_CALLBACK_CANCEL;
1892} 1947}
1948#endif
1893 1949
1894#define SVSZ(_n) \ 1950#define SVSZ(_n) \
1895 md = ((head >> (4 * _n)) & 0xf); \ 1951 md = ((head >> (4 * _n)) & 0xf); \
@@ -2087,6 +2143,7 @@ ecore_ipc_server_data_process(Ecore_Ipc_Server *svr, void *data, int size, Eina_
2087 return ECORE_CALLBACK_CANCEL; 2143 return ECORE_CALLBACK_CANCEL;
2088} 2144}
2089 2145
2146#ifndef EFL_NET_SERVER_UNIX_CLASS
2090static Eina_Bool 2147static Eina_Bool
2091_ecore_ipc_event_server_data(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev) 2148_ecore_ipc_event_server_data(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev)
2092{ 2149{
@@ -2111,6 +2168,7 @@ _ecore_ipc_event_server_data(void *data EINA_UNUSED, int ev_type EINA_UNUSED, vo
2111 } 2168 }
2112 return ECORE_CALLBACK_CANCEL; 2169 return ECORE_CALLBACK_CANCEL;
2113} 2170}
2171#endif
2114 2172
2115static void 2173static void
2116_ecore_ipc_event_client_add_free(void *data EINA_UNUSED, void *ev) 2174_ecore_ipc_event_client_add_free(void *data EINA_UNUSED, void *ev)
diff --git a/src/lib/ecore_ipc/ecore_ipc_private.h b/src/lib/ecore_ipc/ecore_ipc_private.h
index baf71fd788..8df059417a 100644
--- a/src/lib/ecore_ipc/ecore_ipc_private.h
+++ b/src/lib/ecore_ipc/ecore_ipc_private.h
@@ -74,7 +74,11 @@ struct _Ecore_Ipc_Client
74 Eo *send_copier; 74 Eo *send_copier;
75 } socket; 75 } socket;
76 76
77#ifndef EFL_NET_SERVER_UNIX_CLASS
78 /* legacy until Windows and others have their local socket */
77 Ecore_Con_Client *client; 79 Ecore_Con_Client *client;
80#endif
81
78 Ecore_Ipc_Server *svr; 82 Ecore_Ipc_Server *svr;
79 void *data; 83 void *data;
80 unsigned char *buf; 84 unsigned char *buf;
@@ -103,7 +107,10 @@ struct _Ecore_Ipc_Server
103 107
104 Eo *server; 108 Eo *server;
105 109
110#ifndef EFL_NET_SERVER_UNIX_CLASS
106 Ecore_Con_Server *legacy_server; 111 Ecore_Con_Server *legacy_server;
112#endif
113
107 Eina_List *clients; 114 Eina_List *clients;
108 void *data; 115 void *data;
109 unsigned char *buf; 116 unsigned char *buf;