forked from enlightenment/efl
revert ecore-con refcounting stuff, fix the problem in ipc (hopefully)
wfm SVN revision: 71738
This commit is contained in:
parent
564ad86a36
commit
eee42b60d9
|
@ -665,12 +665,6 @@
|
||||||
|
|
||||||
2012-05-24 Carsten Haitzler (The Rasterman)
|
2012-05-24 Carsten Haitzler (The Rasterman)
|
||||||
|
|
||||||
* Add ecore_con_client_ref() and ecore_con_client_unref()
|
|
||||||
* Fix ecore_con to obey reference counting for con clients
|
|
||||||
* Fix lurking bug in ecore_ipc that had it be able to crash in
|
|
||||||
accessind already deleted ecore-con clients. use client
|
|
||||||
ref/unref to fix it. No backport of this fix as it requires a
|
|
||||||
new feature.
|
|
||||||
* Fix ecore-thread scheduling issue where re-scheduled threads
|
* Fix ecore-thread scheduling issue where re-scheduled threads
|
||||||
will hold a loop busy and not allow feedback workers to run,
|
will hold a loop busy and not allow feedback workers to run,
|
||||||
so now have fairer scheduling.
|
so now have fairer scheduling.
|
||||||
|
|
|
@ -1245,27 +1245,7 @@ EAPI Eina_Bool ecore_con_client_connected_get(Ecore_Con_Client *cl);
|
||||||
* Use this function to return the port on which a given client has connected.
|
* Use this function to return the port on which a given client has connected.
|
||||||
*/
|
*/
|
||||||
EAPI int ecore_con_client_port_get(Ecore_Con_Client *cl);
|
EAPI int ecore_con_client_port_get(Ecore_Con_Client *cl);
|
||||||
/**
|
|
||||||
* @brief increment the references on a connection client
|
|
||||||
*
|
|
||||||
* @param cl The client
|
|
||||||
* This increases the references on the given client to keep it alive in
|
|
||||||
* memory for longer until all references are release by
|
|
||||||
* ecore_con_client_unref().
|
|
||||||
* @since 1.3
|
|
||||||
*/
|
|
||||||
EAPI void ecore_con_client_ref(Ecore_Con_Client *cl);
|
|
||||||
/**
|
|
||||||
* @brief decrement the references on a connection client
|
|
||||||
*
|
|
||||||
* @param cl The client
|
|
||||||
* This decrements the references on the given client and once references hit
|
|
||||||
* 0, the client is deleted. ecore_con_client_del() does the same thing as
|
|
||||||
* ecore_con_client_unref(). All con clients start with a reference count of
|
|
||||||
* 1.
|
|
||||||
* @since 1.3
|
|
||||||
*/
|
|
||||||
EAPI void ecore_con_client_unref(Ecore_Con_Client *cl);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -116,12 +116,9 @@ _ecore_con_client_kill(Ecore_Con_Client *cl)
|
||||||
}
|
}
|
||||||
INF("Lost client %s", (cl->ip) ? cl->ip : "");
|
INF("Lost client %s", (cl->ip) ? cl->ip : "");
|
||||||
if (cl->fd_handler)
|
if (cl->fd_handler)
|
||||||
{
|
ecore_main_fd_handler_del(cl->fd_handler);
|
||||||
ecore_main_fd_handler_del(cl->fd_handler);
|
|
||||||
cl->fd_handler = NULL;
|
cl->fd_handler = NULL;
|
||||||
}
|
|
||||||
if (cl->ref <= 0)
|
|
||||||
_ecore_con_client_free(cl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -133,10 +130,9 @@ _ecore_con_server_kill(Ecore_Con_Server *svr)
|
||||||
ecore_con_event_server_del(svr);
|
ecore_con_event_server_del(svr);
|
||||||
|
|
||||||
if (svr->fd_handler)
|
if (svr->fd_handler)
|
||||||
{
|
ecore_main_fd_handler_del(svr->fd_handler);
|
||||||
ecore_main_fd_handler_del(svr->fd_handler);
|
|
||||||
svr->fd_handler = NULL;
|
svr->fd_handler = NULL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define _ecore_con_server_kill(svr) do { \
|
#define _ecore_con_server_kill(svr) do { \
|
||||||
|
@ -872,34 +868,11 @@ ecore_con_client_del(Ecore_Con_Client *cl)
|
||||||
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, "ecore_con_client_del");
|
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, "ecore_con_client_del");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ecore_con_client_unref(cl);
|
|
||||||
|
_ecore_con_client_kill(cl);
|
||||||
return cl->data;
|
return cl->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
EAPI void
|
|
||||||
ecore_con_client_ref(Ecore_Con_Client *cl)
|
|
||||||
{
|
|
||||||
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
|
|
||||||
{
|
|
||||||
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, "ecore_con_client_ref");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cl->ref++;
|
|
||||||
}
|
|
||||||
|
|
||||||
EAPI void
|
|
||||||
ecore_con_client_unref(Ecore_Con_Client *cl)
|
|
||||||
{
|
|
||||||
if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT))
|
|
||||||
{
|
|
||||||
ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, "ecore_con_client_unref");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
cl->ref--;
|
|
||||||
if (cl->ref <= 0)
|
|
||||||
_ecore_con_client_kill(cl);
|
|
||||||
}
|
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
ecore_con_client_data_set(Ecore_Con_Client *cl,
|
ecore_con_client_data_set(Ecore_Con_Client *cl,
|
||||||
const void *data)
|
const void *data)
|
||||||
|
@ -1862,7 +1835,6 @@ _ecore_con_svr_tcp_handler(void *data,
|
||||||
return ECORE_CALLBACK_RENEW;
|
return ECORE_CALLBACK_RENEW;
|
||||||
}
|
}
|
||||||
cl->host_server = svr;
|
cl->host_server = svr;
|
||||||
cl->ref = 1;
|
|
||||||
|
|
||||||
client_addr_len = sizeof(client_addr);
|
client_addr_len = sizeof(client_addr);
|
||||||
memset(&client_addr, 0, client_addr_len);
|
memset(&client_addr, 0, client_addr_len);
|
||||||
|
@ -2412,7 +2384,7 @@ _ecore_con_event_client_del_free(Ecore_Con_Server *svr,
|
||||||
_ecore_con_server_free(svr);
|
_ecore_con_server_free(svr);
|
||||||
}
|
}
|
||||||
if (!e->client->event_count)
|
if (!e->client->event_count)
|
||||||
ecore_con_client_del(e->client);
|
_ecore_con_client_free(e->client);
|
||||||
}
|
}
|
||||||
ecore_con_event_client_del_free(e);
|
ecore_con_event_client_del_free(e);
|
||||||
_ecore_con_event_count--;
|
_ecore_con_event_count--;
|
||||||
|
|
|
@ -120,7 +120,6 @@ struct _Ecore_Con_Client
|
||||||
SSL *ssl;
|
SSL *ssl;
|
||||||
int ssl_err;
|
int ssl_err;
|
||||||
#endif
|
#endif
|
||||||
int ref;
|
|
||||||
Ecore_Con_Ssl_State ssl_state;
|
Ecore_Con_Ssl_State ssl_state;
|
||||||
Eina_Bool handshaking : 1;
|
Eina_Bool handshaking : 1;
|
||||||
Eina_Bool upgrade : 1; /* STARTTLS queued */
|
Eina_Bool upgrade : 1; /* STARTTLS queued */
|
||||||
|
|
|
@ -477,7 +477,7 @@ ecore_ipc_server_del(Ecore_Ipc_Server *svr)
|
||||||
|
|
||||||
EINA_LIST_FREE(svr->clients, cl)
|
EINA_LIST_FREE(svr->clients, cl)
|
||||||
ecore_ipc_client_del(cl);
|
ecore_ipc_client_del(cl);
|
||||||
ecore_con_server_del(svr->server);
|
if (svr->server) ecore_con_server_del(svr->server);
|
||||||
servers = eina_list_remove(servers, svr);
|
servers = eina_list_remove(servers, svr);
|
||||||
|
|
||||||
if (svr->buf) free(svr->buf);
|
if (svr->buf) free(svr->buf);
|
||||||
|
@ -814,6 +814,8 @@ ecore_ipc_client_send(Ecore_Ipc_Client *cl, int major, int minor, int ref, int r
|
||||||
"ecore_ipc_client_send");
|
"ecore_ipc_client_send");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
EINA_SAFETY_ON_TRUE_RETURN_VAL(!cl->client, 0);
|
||||||
|
EINA_SAFETY_ON_TRUE_RETURN_VAL(!ecore_con_client_connected_get(cl->client), 0);
|
||||||
if (size < 0) size = 0;
|
if (size < 0) size = 0;
|
||||||
msg.major = major;
|
msg.major = major;
|
||||||
msg.minor = minor;
|
msg.minor = minor;
|
||||||
|
@ -857,7 +859,7 @@ ecore_ipc_client_server_get(Ecore_Ipc_Client *cl)
|
||||||
"ecore_ipc_client_server_get");
|
"ecore_ipc_client_server_get");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return (ecore_con_server_data_get(ecore_con_client_server_get(cl->client)));
|
return cl->svr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -884,8 +886,8 @@ ecore_ipc_client_del(Ecore_Ipc_Client *cl)
|
||||||
cl->delete_me = 1;
|
cl->delete_me = 1;
|
||||||
if (cl->event_count == 0)
|
if (cl->event_count == 0)
|
||||||
{
|
{
|
||||||
svr = ecore_con_server_data_get(ecore_con_client_server_get(cl->client));
|
svr = cl->svr;
|
||||||
ecore_con_client_unref(cl->client);
|
if (cl->client) ecore_con_client_del(cl->client);
|
||||||
svr->clients = eina_list_remove(svr->clients, cl);
|
svr->clients = eina_list_remove(svr->clients, cl);
|
||||||
if (cl->buf) free(cl->buf);
|
if (cl->buf) free(cl->buf);
|
||||||
ECORE_MAGIC_SET(cl, ECORE_MAGIC_NONE);
|
ECORE_MAGIC_SET(cl, ECORE_MAGIC_NONE);
|
||||||
|
@ -1025,20 +1027,20 @@ static Eina_Bool
|
||||||
_ecore_ipc_event_client_add(void *data __UNUSED__, int ev_type __UNUSED__, void *ev)
|
_ecore_ipc_event_client_add(void *data __UNUSED__, int ev_type __UNUSED__, void *ev)
|
||||||
{
|
{
|
||||||
Ecore_Con_Event_Client_Add *e;
|
Ecore_Con_Event_Client_Add *e;
|
||||||
|
Ecore_Ipc_Server *svr;
|
||||||
|
|
||||||
e = ev;
|
e = ev;
|
||||||
if (!eina_list_data_find(servers, ecore_con_server_data_get(ecore_con_client_server_get(e->client)))) return ECORE_CALLBACK_RENEW;
|
svr = ecore_con_server_data_get(ecore_con_client_server_get(e->client));
|
||||||
|
if (!eina_list_data_find(servers, svr)) return ECORE_CALLBACK_RENEW;
|
||||||
/* handling code here */
|
/* handling code here */
|
||||||
{
|
{
|
||||||
Ecore_Ipc_Client *cl;
|
Ecore_Ipc_Client *cl;
|
||||||
Ecore_Ipc_Server *svr;
|
|
||||||
|
|
||||||
cl = calloc(1, sizeof(Ecore_Ipc_Client));
|
cl = calloc(1, sizeof(Ecore_Ipc_Client));
|
||||||
if (!cl) return ECORE_CALLBACK_CANCEL;
|
if (!cl) return ECORE_CALLBACK_CANCEL;
|
||||||
svr = ecore_con_server_data_get(ecore_con_client_server_get(e->client));
|
cl->svr = svr;
|
||||||
ECORE_MAGIC_SET(cl, ECORE_MAGIC_IPC_CLIENT);
|
ECORE_MAGIC_SET(cl, ECORE_MAGIC_IPC_CLIENT);
|
||||||
cl->client = e->client;
|
cl->client = e->client;
|
||||||
ecore_con_client_ref(cl->client);
|
|
||||||
cl->max_buf_size = 32 * 1024;
|
cl->max_buf_size = 32 * 1024;
|
||||||
ecore_con_client_data_set(cl->client, (void *)cl);
|
ecore_con_client_data_set(cl->client, (void *)cl);
|
||||||
svr->clients = eina_list_append(svr->clients, cl);
|
svr->clients = eina_list_append(svr->clients, cl);
|
||||||
|
@ -1064,19 +1066,21 @@ static Eina_Bool
|
||||||
_ecore_ipc_event_client_del(void *data __UNUSED__, int ev_type __UNUSED__, void *ev)
|
_ecore_ipc_event_client_del(void *data __UNUSED__, int ev_type __UNUSED__, void *ev)
|
||||||
{
|
{
|
||||||
Ecore_Con_Event_Client_Del *e;
|
Ecore_Con_Event_Client_Del *e;
|
||||||
|
Ecore_Ipc_Server *svr;
|
||||||
|
|
||||||
e = ev;
|
e = ev;
|
||||||
if (!eina_list_data_find(servers, ecore_con_server_data_get(ecore_con_client_server_get(e->client)))) return ECORE_CALLBACK_RENEW;
|
if (!e->client) return ECORE_CALLBACK_RENEW;
|
||||||
|
svr = ecore_con_server_data_get(ecore_con_client_server_get(e->client));
|
||||||
|
if (!eina_list_data_find(servers, svr)) return ECORE_CALLBACK_RENEW;
|
||||||
/* handling code here */
|
/* handling code here */
|
||||||
{
|
{
|
||||||
Ecore_Ipc_Client *cl;
|
Ecore_Ipc_Client *cl;
|
||||||
|
|
||||||
cl = ecore_con_client_data_get(e->client);
|
cl = ecore_con_client_data_get(e->client);
|
||||||
|
cl->client = NULL;
|
||||||
{
|
{
|
||||||
Ecore_Ipc_Event_Client_Del *e2;
|
Ecore_Ipc_Event_Client_Del *e2;
|
||||||
Ecore_Ipc_Server *svr;
|
|
||||||
|
|
||||||
svr = ecore_con_server_data_get(ecore_con_client_server_get(e->client));
|
|
||||||
svr->client_list = eina_list_remove(svr->client_list, cl);
|
svr->client_list = eina_list_remove(svr->client_list, cl);
|
||||||
if (!cl->delete_me)
|
if (!cl->delete_me)
|
||||||
{
|
{
|
||||||
|
@ -1135,6 +1139,7 @@ _ecore_ipc_event_server_del(void *data __UNUSED__, int ev_type __UNUSED__, void
|
||||||
Ecore_Ipc_Server *svr;
|
Ecore_Ipc_Server *svr;
|
||||||
|
|
||||||
svr = ecore_con_server_data_get(e->server);
|
svr = ecore_con_server_data_get(e->server);
|
||||||
|
svr->server = NULL;
|
||||||
if (!svr->delete_me)
|
if (!svr->delete_me)
|
||||||
{
|
{
|
||||||
Ecore_Ipc_Event_Server_Del *e2;
|
Ecore_Ipc_Event_Server_Del *e2;
|
||||||
|
@ -1197,9 +1202,11 @@ static Eina_Bool
|
||||||
_ecore_ipc_event_client_data(void *data __UNUSED__, int ev_type __UNUSED__, void *ev)
|
_ecore_ipc_event_client_data(void *data __UNUSED__, int ev_type __UNUSED__, void *ev)
|
||||||
{
|
{
|
||||||
Ecore_Con_Event_Client_Data *e;
|
Ecore_Con_Event_Client_Data *e;
|
||||||
|
Ecore_Ipc_Server *svr;
|
||||||
|
|
||||||
e = ev;
|
e = ev;
|
||||||
if (!eina_list_data_find(servers, ecore_con_server_data_get(ecore_con_client_server_get(e->client)))) return ECORE_CALLBACK_RENEW;
|
svr = ecore_con_server_data_get(ecore_con_client_server_get(e->client));
|
||||||
|
if (!eina_list_data_find(servers, svr)) return ECORE_CALLBACK_RENEW;
|
||||||
/* handling code here */
|
/* handling code here */
|
||||||
{
|
{
|
||||||
Ecore_Ipc_Client *cl;
|
Ecore_Ipc_Client *cl;
|
||||||
|
@ -1268,11 +1275,9 @@ _ecore_ipc_event_client_data(void *data __UNUSED__, int ev_type __UNUSED__, void
|
||||||
if ((cl->buf_size - offset) >= (s + msg.size))
|
if ((cl->buf_size - offset) >= (s + msg.size))
|
||||||
{
|
{
|
||||||
Ecore_Ipc_Event_Client_Data *e2;
|
Ecore_Ipc_Event_Client_Data *e2;
|
||||||
Ecore_Ipc_Server *svr;
|
|
||||||
int max, max2;
|
int max, max2;
|
||||||
|
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
svr = ecore_con_server_data_get(ecore_con_client_server_get(cl->client));
|
|
||||||
max = svr->max_buf_size;
|
max = svr->max_buf_size;
|
||||||
max2 = cl->max_buf_size;
|
max2 = cl->max_buf_size;
|
||||||
if ((max >= 0) && (max2 >= 0))
|
if ((max >= 0) && (max2 >= 0))
|
||||||
|
|
|
@ -70,6 +70,7 @@ struct _Ecore_Ipc_Client
|
||||||
{
|
{
|
||||||
ECORE_MAGIC;
|
ECORE_MAGIC;
|
||||||
Ecore_Con_Client *client;
|
Ecore_Con_Client *client;
|
||||||
|
Ecore_Ipc_Server *svr;
|
||||||
void *data;
|
void *data;
|
||||||
unsigned char *buf;
|
unsigned char *buf;
|
||||||
int buf_size;
|
int buf_size;
|
||||||
|
|
Loading…
Reference in New Issue