summaryrefslogtreecommitdiff
path: root/src/lib/ecore_con/efl_net_server_unix.c
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-11-25 05:32:16 -0200
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>2016-11-25 17:25:18 -0200
commit410d65900c9ce4daa412047c8b49312b98a1d353 (patch)
tree8499d695fa5d8dd9e987a16b966a8f066abfe9b4 /src/lib/ecore_con/efl_net_server_unix.c
parentc534d7912434d0d0fdc6adf1941f0bddac640dd7 (diff)
efl_net_server: add 'client_announce', share logic and fix a bug.
I just realized that if a client is not referenced it would leak in the 'ssl' server as we must del it. However, if we del the SSL socket, we're going to close the underlying TCP. But we're from the TCP "client,add" callback and this causes issues since "closed" will be emitted, our close callback will unparent the client, which lead to it being deleted. The proper solution is to only monitor "closed" if the client is accepted. Otherwise we just check if it was closed, if we're the parent, etc... Fixing this in all servers were painful, we could share since most inherit from Efl.Net.Server.Fd. Then add the "client_announce" protected method to do it, and document how it should work.
Diffstat (limited to '')
-rw-r--r--src/lib/ecore_con/efl_net_server_unix.c29
1 files changed, 1 insertions, 28 deletions
diff --git a/src/lib/ecore_con/efl_net_server_unix.c b/src/lib/ecore_con/efl_net_server_unix.c
index 288c530c75..53deb4d3e1 100644
--- a/src/lib/ecore_con/efl_net_server_unix.c
+++ b/src/lib/ecore_con/efl_net_server_unix.c
@@ -223,29 +223,10 @@ _efl_net_server_unix_efl_net_server_serve(Eo *o, Efl_Net_Server_Unix_Data *pd, c
223 return _efl_net_server_unix_bind(o, pd); 223 return _efl_net_server_unix_bind(o, pd);
224} 224}
225 225
226static Efl_Callback_Array_Item *_efl_net_server_unix_client_cbs(void);
227
228static void
229_efl_net_server_unix_client_event_closed(void *data, const Efl_Event *event)
230{
231 Eo *server = data;
232 Eo *client = event->object;
233
234 efl_event_callback_array_del(client, _efl_net_server_unix_client_cbs(), server);
235 if (efl_parent_get(client) == server)
236 efl_parent_set(client, NULL);
237
238 efl_net_server_clients_count_set(server, efl_net_server_clients_count_get(server) - 1);
239}
240
241EFL_CALLBACKS_ARRAY_DEFINE(_efl_net_server_unix_client_cbs,
242 { EFL_IO_CLOSER_EVENT_CLOSED, _efl_net_server_unix_client_event_closed });
243
244static void 226static void
245_efl_net_server_unix_efl_net_server_fd_client_add(Eo *o, Efl_Net_Server_Unix_Data *pd EINA_UNUSED, int client_fd) 227_efl_net_server_unix_efl_net_server_fd_client_add(Eo *o, Efl_Net_Server_Unix_Data *pd EINA_UNUSED, int client_fd)
246{ 228{
247 Eo *client = efl_add(EFL_NET_SOCKET_UNIX_CLASS, o, 229 Eo *client = efl_add(EFL_NET_SOCKET_UNIX_CLASS, o,
248 efl_event_callback_array_add(efl_added, _efl_net_server_unix_client_cbs(), o),
249 efl_io_closer_close_on_exec_set(efl_added, efl_net_server_fd_close_on_exec_get(o)), 230 efl_io_closer_close_on_exec_set(efl_added, efl_net_server_fd_close_on_exec_get(o)),
250 efl_io_closer_close_on_destructor_set(efl_added, EINA_TRUE), 231 efl_io_closer_close_on_destructor_set(efl_added, EINA_TRUE),
251 efl_loop_fd_set(efl_added, client_fd)); 232 efl_loop_fd_set(efl_added, client_fd));
@@ -256,15 +237,7 @@ _efl_net_server_unix_efl_net_server_fd_client_add(Eo *o, Efl_Net_Server_Unix_Dat
256 return; 237 return;
257 } 238 }
258 239
259 efl_net_server_clients_count_set(o, efl_net_server_clients_count_get(o) + 1); 240 efl_net_server_client_announce(o, client);
260 efl_event_callback_call(o, EFL_NET_SERVER_EVENT_CLIENT_ADD, client);
261
262 if (efl_ref_get(client) == 1) /* users must take a reference themselves */
263 {
264 DBG("client %s was not handled, closing it...",
265 efl_net_socket_address_remote_get(client));
266 efl_del(client);
267 }
268} 241}
269 242
270static void 243static void