forked from enlightenment/efl
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.
This commit is contained in:
parent
400f3932d9
commit
9805f4ec36
|
@ -199,12 +199,16 @@ _ecore_ipc_ddlt_int(int in, int prev, int mode)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* 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 */
|
||||
#ifndef EFL_NET_SERVER_UNIX_CLASS
|
||||
static Eina_Bool _ecore_ipc_event_client_add(void *data, int ev_type, void *ev);
|
||||
static Eina_Bool _ecore_ipc_event_client_del(void *data, int ev_type, void *ev);
|
||||
static Eina_Bool _ecore_ipc_event_server_add(void *data, int ev_type, void *ev);
|
||||
static Eina_Bool _ecore_ipc_event_server_del(void *data, int ev_type, void *ev);
|
||||
static Eina_Bool _ecore_ipc_event_client_data(void *data, int ev_type, void *ev);
|
||||
static Eina_Bool _ecore_ipc_event_server_data(void *data, int ev_type, void *ev);
|
||||
#endif
|
||||
|
||||
static void _ecore_ipc_event_client_add_free(void *data, void *ev);
|
||||
static void _ecore_ipc_event_client_del_free(void *data, void *ev);
|
||||
static void _ecore_ipc_event_client_data_free(void *data, void *ev);
|
||||
|
@ -221,7 +225,10 @@ EAPI int ECORE_IPC_EVENT_SERVER_DATA = 0;
|
|||
|
||||
static int _ecore_ipc_init_count = 0;
|
||||
static Eina_List *servers = NULL;
|
||||
|
||||
#ifndef EFL_NET_SERVER_UNIX_CLASS
|
||||
static Ecore_Event_Handler *handler[6];
|
||||
#endif
|
||||
|
||||
static void
|
||||
ecore_ipc_post_event_server_add(Ecore_Ipc_Server *svr)
|
||||
|
@ -306,7 +313,9 @@ ecore_ipc_client_add(Ecore_Ipc_Server *svr)
|
|||
EAPI int
|
||||
ecore_ipc_init(void)
|
||||
{
|
||||
#ifndef EFL_NET_SERVER_UNIX_CLASS
|
||||
int i = 0;
|
||||
#endif
|
||||
|
||||
if (++_ecore_ipc_init_count != 1)
|
||||
return _ecore_ipc_init_count;
|
||||
|
@ -327,6 +336,7 @@ ecore_ipc_init(void)
|
|||
ECORE_IPC_EVENT_CLIENT_DATA = ecore_event_type_new();
|
||||
ECORE_IPC_EVENT_SERVER_DATA = ecore_event_type_new();
|
||||
|
||||
#ifndef EFL_NET_SERVER_UNIX_CLASS
|
||||
handler[i++] = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD,
|
||||
_ecore_ipc_event_client_add, NULL);
|
||||
handler[i++] = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL,
|
||||
|
@ -339,13 +349,16 @@ ecore_ipc_init(void)
|
|||
_ecore_ipc_event_client_data, NULL);
|
||||
handler[i] = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA,
|
||||
_ecore_ipc_event_server_data, NULL);
|
||||
#endif
|
||||
return _ecore_ipc_init_count;
|
||||
}
|
||||
|
||||
EAPI int
|
||||
ecore_ipc_shutdown(void)
|
||||
{
|
||||
#ifndef EFL_NET_SERVER_UNIX_CLASS
|
||||
int i;
|
||||
#endif
|
||||
|
||||
if (--_ecore_ipc_init_count != 0)
|
||||
return _ecore_ipc_init_count;
|
||||
|
@ -355,8 +368,10 @@ ecore_ipc_shutdown(void)
|
|||
EINA_LIST_FOREACH_SAFE(servers, l, l2, svr)
|
||||
ecore_ipc_server_del(svr);
|
||||
|
||||
#ifndef EFL_NET_SERVER_UNIX_CLASS
|
||||
for (i = 0; i < 6; i++)
|
||||
ecore_event_handler_del(handler[i]);
|
||||
#endif
|
||||
|
||||
ecore_con_shutdown();
|
||||
eina_log_domain_unregister(_ecore_ipc_log_dom);
|
||||
|
@ -384,7 +399,7 @@ EFL_CALLBACKS_ARRAY_DEFINE(_ecore_ipc_server_cbs,
|
|||
|
||||
#ifndef EFL_NET_SERVER_UNIX_CLASS
|
||||
static Ecore_Ipc_Server *
|
||||
ecore_ipc_server_add_legacy(Ecore_Ipc_Type compl_type, char *name, int port, const void *data)
|
||||
ecore_ipc_server_add_legacy(Ecore_Ipc_Type compl_type, const char *name, int port, const void *data)
|
||||
{
|
||||
Ecore_Ipc_Server *svr;
|
||||
Ecore_Ipc_Type type;
|
||||
|
@ -915,7 +930,9 @@ ecore_ipc_server_del(Ecore_Ipc_Server *svr)
|
|||
|
||||
if (svr->dialer.dialer) _ecore_ipc_dialer_del(svr);
|
||||
if (svr->server) _ecore_ipc_server_del(svr);
|
||||
#ifndef EFL_NET_SERVER_UNIX_CLASS
|
||||
if (svr->legacy_server) ecore_con_server_del(svr->legacy_server);
|
||||
#endif
|
||||
servers = eina_list_remove(servers, svr);
|
||||
|
||||
if (svr->buf) free(svr->buf);
|
||||
|
@ -952,9 +969,13 @@ ecore_ipc_server_connected_get(Ecore_Ipc_Server *svr)
|
|||
if (svr->dialer.dialer)
|
||||
return efl_net_dialer_connected_get(svr->dialer.dialer);
|
||||
else if (svr->server) return EINA_TRUE;
|
||||
#ifndef EFL_NET_SERVER_UNIX_CLASS
|
||||
else if (!svr->legacy_server) return EINA_FALSE;
|
||||
|
||||
return ecore_con_server_connected_get(svr->legacy_server);
|
||||
#else
|
||||
return EINA_FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
EAPI Eina_List *
|
||||
|
@ -1006,7 +1027,6 @@ EAPI int
|
|||
ecore_ipc_server_send(Ecore_Ipc_Server *svr, int major, int minor, int ref, int ref_to, int response, const void *data, int size)
|
||||
{
|
||||
Ecore_Ipc_Msg_Head msg;
|
||||
int ret;
|
||||
int *head, md = 0, d, s;
|
||||
unsigned char dat[sizeof(Ecore_Ipc_Msg_Head)];
|
||||
|
||||
|
@ -1084,11 +1104,19 @@ ecore_ipc_server_send(Ecore_Ipc_Server *svr, int major, int minor, int ref, int
|
|||
ERR("Send data to clients, not the server handle");
|
||||
return 0;
|
||||
}
|
||||
#ifndef EFL_NET_SERVER_UNIX_CLASS
|
||||
else if (!svr->legacy_server) return 0;
|
||||
|
||||
ret = ecore_con_server_send(svr->legacy_server, dat, s);
|
||||
if (size > 0) ret += ecore_con_server_send(svr->legacy_server, data, size);
|
||||
return ret;
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ecore_con_server_send(svr->legacy_server, dat, s);
|
||||
if (size > 0) ret += ecore_con_server_send(svr->legacy_server, data, size);
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
EAPI void
|
||||
|
@ -1105,8 +1133,10 @@ ecore_ipc_server_client_limit_set(Ecore_Ipc_Server *svr, int client_limit, char
|
|||
efl_net_server_clients_limit_set(svr->server, client_limit, reject_excess_clients);
|
||||
return;
|
||||
}
|
||||
#ifndef EFL_NET_SERVER_UNIX_CLASS
|
||||
else if (!svr->legacy_server) return;
|
||||
ecore_con_server_client_limit_set(svr->legacy_server, client_limit, reject_excess_clients);
|
||||
#endif
|
||||
}
|
||||
|
||||
EAPI void
|
||||
|
@ -1159,9 +1189,13 @@ ecore_ipc_server_ip_get(Ecore_Ipc_Server *svr)
|
|||
/* original IPC just returned IP for remote connections */
|
||||
return NULL;
|
||||
}
|
||||
#ifndef EFL_NET_SERVER_UNIX_CLASS
|
||||
else if (!svr->legacy_server) return NULL;
|
||||
|
||||
return ecore_con_server_ip_get(svr->legacy_server);
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
EAPI void
|
||||
|
@ -1184,9 +1218,11 @@ ecore_ipc_server_flush(Ecore_Ipc_Server *svr)
|
|||
ERR("Flush clients, not the server handle");
|
||||
return;
|
||||
}
|
||||
#ifndef EFL_NET_SERVER_UNIX_CLASS
|
||||
else if (!svr->legacy_server) return;
|
||||
|
||||
ecore_con_server_flush(svr->legacy_server);
|
||||
#endif
|
||||
}
|
||||
|
||||
#define CLENC(_member) \
|
||||
|
@ -1226,7 +1262,6 @@ EAPI int
|
|||
ecore_ipc_client_send(Ecore_Ipc_Client *cl, int major, int minor, int ref, int ref_to, int response, const void *data, int size)
|
||||
{
|
||||
Ecore_Ipc_Msg_Head msg;
|
||||
int ret;
|
||||
int *head, md = 0, d, s;
|
||||
unsigned char dat[sizeof(Ecore_Ipc_Msg_Head)];
|
||||
|
||||
|
@ -1238,8 +1273,10 @@ ecore_ipc_client_send(Ecore_Ipc_Client *cl, int major, int minor, int ref, int r
|
|||
}
|
||||
if (cl->socket.socket)
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL(efl_io_closer_closed_get(cl->socket.socket), 0);
|
||||
#ifndef EFL_NET_SERVER_UNIX_CLASS
|
||||
else if (cl->client)
|
||||
EINA_SAFETY_ON_TRUE_RETURN_VAL(!ecore_con_client_connected_get(cl->client), 0);
|
||||
#endif
|
||||
else
|
||||
{
|
||||
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
|
|||
|
||||
return s + size;
|
||||
}
|
||||
#ifndef EFL_NET_SERVER_UNIX_CLASS
|
||||
else if (!cl->client) return 0;
|
||||
|
||||
ret = ecore_con_client_send(cl->client, dat, s);
|
||||
if (size > 0) ret += ecore_con_client_send(cl->client, data, size);
|
||||
return ret;
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = ecore_con_client_send(cl->client, dat, s);
|
||||
if (size > 0) ret += ecore_con_client_send(cl->client, data, size);
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
EAPI Ecore_Ipc_Server *
|
||||
|
@ -1482,7 +1527,9 @@ ecore_ipc_client_del(Ecore_Ipc_Client *cl)
|
|||
{
|
||||
svr = cl->svr;
|
||||
if (cl->socket.socket) _ecore_ipc_client_socket_del(cl);
|
||||
#ifndef EFL_NET_SERVER_UNIX_CLASS
|
||||
if (cl->client) ecore_con_client_del(cl->client);
|
||||
#endif
|
||||
if (ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_IPC_SERVER))
|
||||
svr->clients = eina_list_remove(svr->clients, cl);
|
||||
if (cl->buf) free(cl->buf);
|
||||
|
@ -1559,9 +1606,13 @@ ecore_ipc_client_ip_get(Ecore_Ipc_Client *cl)
|
|||
*/
|
||||
return "0.0.0.0";
|
||||
}
|
||||
#ifndef EFL_NET_SERVER_UNIX_CLASS
|
||||
else if (!cl->client) return NULL;
|
||||
|
||||
return ecore_con_client_ip_get(cl->client);
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
EAPI void
|
||||
|
@ -1579,9 +1630,11 @@ ecore_ipc_client_flush(Ecore_Ipc_Client *cl)
|
|||
efl_io_copier_flush(cl->socket.send_copier);
|
||||
return;
|
||||
}
|
||||
#ifndef EFL_NET_SERVER_UNIX_CLASS
|
||||
else if (!cl->client) return;
|
||||
|
||||
ecore_con_client_flush(cl->client);
|
||||
#endif
|
||||
}
|
||||
|
||||
EAPI int
|
||||
|
@ -1590,7 +1643,7 @@ ecore_ipc_ssl_available_get(void)
|
|||
return ecore_con_ssl_available_get();
|
||||
}
|
||||
|
||||
|
||||
#ifndef EFL_NET_SERVER_UNIX_CLASS
|
||||
static Eina_Bool
|
||||
_ecore_ipc_event_client_add(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev)
|
||||
{
|
||||
|
@ -1672,6 +1725,7 @@ _ecore_ipc_event_server_del(void *data EINA_UNUSED, int ev_type EINA_UNUSED, voi
|
|||
}
|
||||
return ECORE_CALLBACK_CANCEL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define CLSZ(_n) \
|
||||
md = ((head >> (4 * _n)) & 0xf); \
|
||||
|
@ -1865,6 +1919,7 @@ ecore_ipc_client_data_process(Ecore_Ipc_Client *cl, void *data, int size, Eina_B
|
|||
return ECORE_CALLBACK_CANCEL;
|
||||
}
|
||||
|
||||
#ifndef EFL_NET_SERVER_UNIX_CLASS
|
||||
static Eina_Bool
|
||||
_ecore_ipc_event_client_data(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev)
|
||||
{
|
||||
|
@ -1890,6 +1945,7 @@ _ecore_ipc_event_client_data(void *data EINA_UNUSED, int ev_type EINA_UNUSED, vo
|
|||
}
|
||||
return ECORE_CALLBACK_CANCEL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#define SVSZ(_n) \
|
||||
md = ((head >> (4 * _n)) & 0xf); \
|
||||
|
@ -2087,6 +2143,7 @@ ecore_ipc_server_data_process(Ecore_Ipc_Server *svr, void *data, int size, Eina_
|
|||
return ECORE_CALLBACK_CANCEL;
|
||||
}
|
||||
|
||||
#ifndef EFL_NET_SERVER_UNIX_CLASS
|
||||
static Eina_Bool
|
||||
_ecore_ipc_event_server_data(void *data EINA_UNUSED, int ev_type EINA_UNUSED, void *ev)
|
||||
{
|
||||
|
@ -2111,6 +2168,7 @@ _ecore_ipc_event_server_data(void *data EINA_UNUSED, int ev_type EINA_UNUSED, vo
|
|||
}
|
||||
return ECORE_CALLBACK_CANCEL;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
_ecore_ipc_event_client_add_free(void *data EINA_UNUSED, void *ev)
|
||||
|
|
|
@ -74,7 +74,11 @@ struct _Ecore_Ipc_Client
|
|||
Eo *send_copier;
|
||||
} socket;
|
||||
|
||||
#ifndef EFL_NET_SERVER_UNIX_CLASS
|
||||
/* legacy until Windows and others have their local socket */
|
||||
Ecore_Con_Client *client;
|
||||
#endif
|
||||
|
||||
Ecore_Ipc_Server *svr;
|
||||
void *data;
|
||||
unsigned char *buf;
|
||||
|
@ -103,7 +107,10 @@ struct _Ecore_Ipc_Server
|
|||
|
||||
Eo *server;
|
||||
|
||||
#ifndef EFL_NET_SERVER_UNIX_CLASS
|
||||
Ecore_Con_Server *legacy_server;
|
||||
#endif
|
||||
|
||||
Eina_List *clients;
|
||||
void *data;
|
||||
unsigned char *buf;
|
||||
|
|
Loading…
Reference in New Issue