From: Guilherme Iscaro Date: Wed, 26 Jul 2017 21:48:45 +0000 (-0300) Subject: Ecore_Conn: Enable CLOEXEC by default. X-Git-Tag: upstream/1.20.0~112 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=45a767632d417043936622f78597c06dc7a8cf94;p=platform%2Fupstream%2Fefl.git Ecore_Conn: Enable CLOEXEC by default. This flag should be enabled by default in order to avoid socket leaks. --- diff --git a/src/bin/efl/efl_debugd.c b/src/bin/efl/efl_debugd.c index cfd83e1..562bd82 100644 --- a/src/bin/efl/efl_debugd.c +++ b/src/bin/efl/efl_debugd.c @@ -634,7 +634,6 @@ _remote_server_create(void) { Eo *inner_server = efl_net_server_simple_inner_server_get(_remote_server); - efl_net_server_fd_close_on_exec_set(inner_server, EINA_TRUE); efl_net_server_fd_reuse_address_set(inner_server, EINA_TRUE); } efl_event_callback_add(_remote_server, EFL_NET_SERVER_EVENT_CLIENT_ADD, _client_add, NULL); diff --git a/src/examples/ecore/efl_net_server_example.c b/src/examples/ecore/efl_net_server_example.c index c3b19ec..277d4c9 100644 --- a/src/examples/ecore/efl_net_server_example.c +++ b/src/examples/ecore/efl_net_server_example.c @@ -652,7 +652,6 @@ main(int argc, char **argv) if (cls == EFL_NET_SERVER_TCP_CLASS) { efl_net_server_tcp_ipv6_only_set(server, ipv6_only); - efl_net_server_fd_close_on_exec_set(server, EINA_TRUE); /* recommended */ efl_net_server_fd_reuse_address_set(server, EINA_TRUE); /* optional, but nice for testing */ efl_net_server_fd_reuse_port_set(server, EINA_TRUE); /* optional, but nice for testing... not secure unless you know what you're doing */ @@ -672,7 +671,6 @@ main(int argc, char **argv) efl_net_server_udp_multicast_join(server, str); - efl_net_server_fd_close_on_exec_set(server, EINA_TRUE); /* recommended */ efl_net_server_fd_reuse_address_set(server, EINA_TRUE); /* optional, but nice for testing */ efl_net_server_fd_reuse_port_set(server, EINA_TRUE); /* optional, but nice for testing... not secure unless you know what you're doing */ if (socket_activated) efl_net_server_fd_socket_activate(server, address); @@ -704,7 +702,6 @@ main(int argc, char **argv) efl_net_server_ssl_context_set(server, ssl_ctx); - efl_net_server_ssl_close_on_exec_set(server, EINA_TRUE); /* recommended */ efl_net_server_ssl_reuse_address_set(server, EINA_TRUE); /* optional, but nice for testing */ efl_net_server_ssl_reuse_port_set(server, EINA_TRUE); /* optional, but nice for testing... not secure unless you know what you're doing */ if (socket_activated) efl_net_server_ssl_socket_activate(server, address); diff --git a/src/examples/ecore/efl_net_server_simple_example.c b/src/examples/ecore/efl_net_server_simple_example.c index ddce4c8..6cafe9d 100644 --- a/src/examples/ecore/efl_net_server_simple_example.c +++ b/src/examples/ecore/efl_net_server_simple_example.c @@ -460,7 +460,6 @@ main(int argc, char **argv) if (cls == EFL_NET_SERVER_TCP_CLASS) { efl_net_server_tcp_ipv6_only_set(server, ipv6_only); - efl_net_server_fd_close_on_exec_set(server, EINA_TRUE); /* recommended */ efl_net_server_fd_reuse_address_set(server, EINA_TRUE); /* optional, but nice for testing */ efl_net_server_fd_reuse_port_set(server, EINA_TRUE); /* optional, but nice for testing... not secure unless you know what you're doing */ @@ -479,8 +478,6 @@ main(int argc, char **argv) EINA_LIST_FOREACH(udp_mcast_groups, lst, str) efl_net_server_udp_multicast_join(server, str); - - efl_net_server_fd_close_on_exec_set(server, EINA_TRUE); /* recommended */ efl_net_server_fd_reuse_address_set(server, EINA_TRUE); /* optional, but nice for testing */ efl_net_server_fd_reuse_port_set(server, EINA_TRUE); /* optional, but nice for testing... not secure unless you know what you're doing */ if (socket_activated) efl_net_server_fd_socket_activate(server, address); @@ -512,7 +509,6 @@ main(int argc, char **argv) efl_net_server_ssl_context_set(server, ssl_ctx); - efl_net_server_ssl_close_on_exec_set(server, EINA_TRUE); /* recommended */ efl_net_server_ssl_reuse_address_set(server, EINA_TRUE); /* optional, but nice for testing */ efl_net_server_ssl_reuse_port_set(server, EINA_TRUE); /* optional, but nice for testing... not secure unless you know what you're doing */ if (socket_activated) efl_net_server_ssl_socket_activate(server, address); diff --git a/src/examples/ecore/efl_net_socket_ssl_server_example.c b/src/examples/ecore/efl_net_socket_ssl_server_example.c index caf5f87..129bee4 100644 --- a/src/examples/ecore/efl_net_socket_ssl_server_example.c +++ b/src/examples/ecore/efl_net_socket_ssl_server_example.c @@ -312,7 +312,6 @@ main(int argc, char **argv) server = efl_add(EFL_NET_SERVER_TCP_CLASS, ecore_main_loop_get(), /* it's mandatory to use a main loop provider as the server parent */ efl_net_server_tcp_ipv6_only_set(efl_added, EINA_FALSE), /* optional, but helps testing IPv4 on IPv6 servers */ - efl_net_server_fd_close_on_exec_set(efl_added, EINA_TRUE), /* recommended */ efl_net_server_fd_reuse_address_set(efl_added, EINA_TRUE), /* optional, but nice for testing */ efl_net_server_fd_reuse_port_set(efl_added, EINA_TRUE), /* optional, but nice for testing... not secure unless you know what you're doing */ efl_event_callback_array_add(efl_added, server_cbs(), NULL)); /* mandatory to have "client,add" in order to be useful */ diff --git a/src/lib/ecore_con/ecore_con_legacy.c b/src/lib/ecore_con/ecore_con_legacy.c index 35cdef8..1cb007f 100644 --- a/src/lib/ecore_con/ecore_con_legacy.c +++ b/src/lib/ecore_con/ecore_con_legacy.c @@ -1496,11 +1496,9 @@ _ecore_con_server_server_set(Ecore_Con_Server *svr, Eo *server) if (efl_isa(inner_server, EFL_NET_SERVER_FD_CLASS)) { - efl_net_server_fd_close_on_exec_set(inner_server, EINA_TRUE); efl_net_server_fd_reuse_address_set(inner_server, EINA_TRUE); efl_net_server_fd_reuse_port_set(inner_server, EINA_TRUE); } - if (efl_isa(inner_server, EFL_NET_SERVER_TCP_CLASS)) { /* old ecore_con did not map ipv4 to ipv6... */ @@ -1516,7 +1514,6 @@ _ecore_con_server_server_set(Ecore_Con_Server *svr, Eo *server) { /* old ecore_con did not map ipv4 to ipv6... */ efl_net_server_ssl_ipv6_only_set(inner_server, EINA_TRUE); - efl_net_server_ssl_close_on_exec_set(inner_server, EINA_TRUE); efl_net_server_ssl_reuse_address_set(inner_server, EINA_TRUE); efl_net_server_ssl_reuse_port_set(inner_server, EINA_TRUE); } diff --git a/src/lib/ecore_con/efl_net_server_fd.c b/src/lib/ecore_con/efl_net_server_fd.c index 03448ec..f1ff38b 100644 --- a/src/lib/ecore_con/efl_net_server_fd.c +++ b/src/lib/ecore_con/efl_net_server_fd.c @@ -100,6 +100,7 @@ EOLIAN static Efl_Object * _efl_net_server_fd_efl_object_constructor(Eo *o, Efl_Net_Server_Fd_Data *pd) { pd->family = AF_UNSPEC; + pd->close_on_exec = EINA_TRUE; return efl_constructor(efl_super(o, MY_CLASS)); } diff --git a/src/lib/ecore_con/efl_net_server_fd.eo b/src/lib/ecore_con/efl_net_server_fd.eo index 0b3f55d..6f3ab66 100644 --- a/src/lib/ecore_con/efl_net_server_fd.eo +++ b/src/lib/ecore_con/efl_net_server_fd.eo @@ -71,7 +71,7 @@ class Efl.Net.Server.Fd (Efl.Loop.Fd, Efl.Net.Server) { @property close_on_exec { [[Controls Close-on-Exec() using FD_CLOEXEC. - Children socket will inherit the server's setting by + Children socket will not inherit the server's setting by default. One can change the behavior using each instance @Efl.Io.Closer.close_on_exec.set. ]] diff --git a/src/lib/ecore_con/efl_net_server_ssl.eo b/src/lib/ecore_con/efl_net_server_ssl.eo index d34e2df..594104d 100644 --- a/src/lib/ecore_con/efl_net_server_ssl.eo +++ b/src/lib/ecore_con/efl_net_server_ssl.eo @@ -71,7 +71,7 @@ class Efl.Net.Server.Ssl (Efl.Loop_User, Efl.Net.Server) { @property close_on_exec { [[Controls Close-on-Exec() using FD_CLOEXEC. - Children socket will inherit the server's setting by + Children socket will not inherit the server's setting by default. One can change the behavior using each instance @Efl.Io.Closer.close_on_exec.set. ]] diff --git a/src/lib/ecore_ipc/ecore_ipc.c b/src/lib/ecore_ipc/ecore_ipc.c index 8cb7f3f..0b27496 100644 --- a/src/lib/ecore_ipc/ecore_ipc.c +++ b/src/lib/ecore_ipc/ecore_ipc.c @@ -481,7 +481,6 @@ ecore_ipc_server_add(Ecore_Ipc_Type type, const char *name, int port, const void if (efl_isa(svr->server, EFL_NET_SERVER_FD_CLASS)) { - efl_net_server_fd_close_on_exec_set(svr->server, EINA_TRUE); efl_net_server_fd_reuse_address_set(svr->server, EINA_TRUE); efl_net_server_fd_reuse_port_set(svr->server, EINA_TRUE); } @@ -495,7 +494,6 @@ ecore_ipc_server_add(Ecore_Ipc_Type type, const char *name, int port, const void { /* old ecore_con did not map ipv4 to ipv6... */ efl_net_server_ssl_ipv6_only_set(svr->server, EINA_TRUE); - efl_net_server_ssl_close_on_exec_set(svr->server, EINA_TRUE); efl_net_server_ssl_reuse_address_set(svr->server, EINA_TRUE); efl_net_server_ssl_reuse_port_set(svr->server, EINA_TRUE); }