summaryrefslogtreecommitdiff
path: root/src/lib/ecore_con
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2017-04-18 16:56:01 -0700
committerCedric BAIL <cedric@osg.samsung.com>2017-04-18 16:56:01 -0700
commit662f7d33105029b664b57848cc7afec7bf7a6387 (patch)
treec016644bc1ea6f8392a823aaf615e2fd57f2efc5 /src/lib/ecore_con
parent712f7e878bfe9b49890cd1d67f921f3f1cf5d74a (diff)
ecore_con: use new API eina_file_close_on_exec.
Diffstat (limited to 'src/lib/ecore_con')
-rw-r--r--src/lib/ecore_con/ecore_con.c33
-rw-r--r--src/lib/ecore_con/efl_net_dialer_http.c13
-rw-r--r--src/lib/ecore_con/efl_net_server_fd.c15
3 files changed, 6 insertions, 55 deletions
diff --git a/src/lib/ecore_con/ecore_con.c b/src/lib/ecore_con/ecore_con.c
index 64ac60f910..ce881fa315 100644
--- a/src/lib/ecore_con/ecore_con.c
+++ b/src/lib/ecore_con/ecore_con.c
@@ -587,10 +587,9 @@ efl_net_socket4(int domain, int type, int protocol, Eina_Bool close_on_exec)
587 { 587 {
588 if (close_on_exec) 588 if (close_on_exec)
589 { 589 {
590 if (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0) 590 if (!eina_file_close_on_exec(fd, EINA_TRUE))
591 { 591 {
592 int errno_bkp = errno; 592 int errno_bkp = errno;
593 ERR("fcntl(" SOCKET_FMT ", F_SETFD, FD_CLOEXEC): %s", fd, strerror(errno));
594 closesocket(fd); 593 closesocket(fd);
595 fd = INVALID_SOCKET; 594 fd = INVALID_SOCKET;
596 errno = errno_bkp; 595 errno = errno_bkp;
@@ -815,25 +814,12 @@ _efl_net_connect_async_end(void *data, Ecore_Thread *thread EINA_UNUSED)
815 /* if it wasn't a close on exec, release the socket to be passed to child */ 814 /* if it wasn't a close on exec, release the socket to be passed to child */
816 if ((!d->close_on_exec) && (d->sockfd != INVALID_SOCKET)) 815 if ((!d->close_on_exec) && (d->sockfd != INVALID_SOCKET))
817 { 816 {
818 int flags = fcntl(d->sockfd, F_GETFD); 817 if (!eina_file_close_on_exec(d->sockfd, EINA_FALSE))
819 if (flags < 0)
820 { 818 {
821 d->error = errno; 819 d->error = errno;
822 ERR("fcntl(" SOCKET_FMT ", F_GETFD): %s", d->sockfd, eina_error_msg_get(d->error));
823 closesocket(d->sockfd); 820 closesocket(d->sockfd);
824 d->sockfd = INVALID_SOCKET; 821 d->sockfd = INVALID_SOCKET;
825 } 822 }
826 else
827 {
828 flags &= (~FD_CLOEXEC);
829 if (fcntl(d->sockfd, F_SETFD, flags) < 0)
830 {
831 d->error = errno;
832 ERR("fcntl(" SOCKET_FMT ", F_SETFD, %#x): %s", d->sockfd, flags, eina_error_msg_get(d->error));
833 closesocket(d->sockfd);
834 d->sockfd = INVALID_SOCKET;
835 }
836 }
837 } 823 }
838#endif 824#endif
839 d->cb((void *)d->data, d->addr, d->addrlen, d->sockfd, d->error); 825 d->cb((void *)d->data, d->addr, d->addrlen, d->sockfd, d->error);
@@ -2222,25 +2208,12 @@ _efl_net_ip_connect_async_end(void *data, Ecore_Thread *thread EINA_UNUSED)
2222 /* if it wasn't a close on exec, release the socket to be passed to child */ 2208 /* if it wasn't a close on exec, release the socket to be passed to child */
2223 if ((!d->close_on_exec) && (d->sockfd != INVALID_SOCKET)) 2209 if ((!d->close_on_exec) && (d->sockfd != INVALID_SOCKET))
2224 { 2210 {
2225 int flags = fcntl(d->sockfd, F_GETFD); 2211 if (!eina_file_close_on_exec(d->sockfd, EINA_FALSE))
2226 if (flags < 0)
2227 { 2212 {
2228 d->error = errno; 2213 d->error = errno;
2229 ERR("fcntl(" SOCKET_FMT ", F_GETFD): %s", d->sockfd, strerror(errno));
2230 closesocket(d->sockfd); 2214 closesocket(d->sockfd);
2231 d->sockfd = INVALID_SOCKET; 2215 d->sockfd = INVALID_SOCKET;
2232 } 2216 }
2233 else
2234 {
2235 flags &= (~FD_CLOEXEC);
2236 if (fcntl(d->sockfd, F_SETFD, flags) < 0)
2237 {
2238 d->error = errno;
2239 ERR("fcntl(" SOCKET_FMT ", F_SETFD, %#x): %s", d->sockfd, flags, strerror(errno));
2240 closesocket(d->sockfd);
2241 d->sockfd = INVALID_SOCKET;
2242 }
2243 }
2244 } 2217 }
2245#endif 2218#endif
2246 2219
diff --git a/src/lib/ecore_con/efl_net_dialer_http.c b/src/lib/ecore_con/efl_net_dialer_http.c
index 6c4a463a12..8bc273a4ce 100644
--- a/src/lib/ecore_con/efl_net_dialer_http.c
+++ b/src/lib/ecore_con/efl_net_dialer_http.c
@@ -1780,18 +1780,7 @@ _efl_net_dialer_http_efl_io_closer_close_on_exec_set(Eo *o EINA_UNUSED, Efl_Net_
1780 1780
1781 if (pd->fd == INVALID_SOCKET) return EINA_TRUE; /* postpone until _efl_net_dialer_http_socket_open */ 1781 if (pd->fd == INVALID_SOCKET) return EINA_TRUE; /* postpone until _efl_net_dialer_http_socket_open */
1782 1782
1783 flags = fcntl(pd->fd, F_GETFD); 1783 if (!eina_file_close_on_exec(pd->fd, close_on_exec))
1784 if (flags < 0)
1785 {
1786 ERR("fcntl(" SOCKET_FMT ", F_GETFD): %s", pd->fd, strerror(errno));
1787 pd->close_on_exec = old;
1788 return EINA_FALSE;
1789 }
1790 if (close_on_exec)
1791 flags |= FD_CLOEXEC;
1792 else
1793 flags &= (~FD_CLOEXEC);
1794 if (fcntl(pd->fd, F_SETFD, flags) < 0)
1795 { 1784 {
1796 ERR("fcntl(" SOCKET_FMT ", F_SETFD, %#x): %s", pd->fd, flags, strerror(errno)); 1785 ERR("fcntl(" SOCKET_FMT ", F_SETFD, %#x): %s", pd->fd, flags, strerror(errno));
1797 pd->close_on_exec = old; 1786 pd->close_on_exec = old;
diff --git a/src/lib/ecore_con/efl_net_server_fd.c b/src/lib/ecore_con/efl_net_server_fd.c
index 0c76af28fa..de699b268b 100644
--- a/src/lib/ecore_con/efl_net_server_fd.c
+++ b/src/lib/ecore_con/efl_net_server_fd.c
@@ -51,7 +51,7 @@ efl_net_accept4(SOCKET fd, struct sockaddr *addr, socklen_t *addrlen, Eina_Bool
51#ifdef FD_CLOEXEC 51#ifdef FD_CLOEXEC
52 if (close_on_exec) 52 if (close_on_exec)
53 { 53 {
54 if (fcntl(client, F_SETFD, FD_CLOEXEC) < 0) 54 if (!eina_file_close_on_exec(client, EINA_TRUE))
55 { 55 {
56 int errno_bkp = errno; 56 int errno_bkp = errno;
57 ERR("fcntl(" SOCKET_FMT ", F_SETFD, FD_CLOEXEC): %s", client, strerror(errno)); 57 ERR("fcntl(" SOCKET_FMT ", F_SETFD, FD_CLOEXEC): %s", client, strerror(errno));
@@ -280,18 +280,7 @@ _efl_net_server_fd_close_on_exec_set(Eo *o, Efl_Net_Server_Fd_Data *pd, Eina_Boo
280 fd = efl_loop_fd_get(o); 280 fd = efl_loop_fd_get(o);
281 if (fd == INVALID_SOCKET) return EINA_TRUE; /* postpone until fd_set() */ 281 if (fd == INVALID_SOCKET) return EINA_TRUE; /* postpone until fd_set() */
282 282
283 flags = fcntl(fd, F_GETFD); 283 if (!eina_file_close_on_exec(fd, close_on_exec))
284 if (flags < 0)
285 {
286 ERR("fcntl(" SOCKET_FMT ", F_GETFD): %s", fd, strerror(errno));
287 pd->close_on_exec = old;
288 return EINA_FALSE;
289 }
290 if (close_on_exec)
291 flags |= FD_CLOEXEC;
292 else
293 flags &= (~FD_CLOEXEC);
294 if (fcntl(fd, F_SETFD, flags) < 0)
295 { 284 {
296 ERR("fcntl(" SOCKET_FMT ", F_SETFD, %#x): %s", fd, flags, strerror(errno)); 285 ERR("fcntl(" SOCKET_FMT ", F_SETFD, %#x): %s", fd, flags, strerror(errno));
297 pd->close_on_exec = old; 286 pd->close_on_exec = old;