eina,evas,ecore,eio: backport r80434.
authorcedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 7 Dec 2012 11:05:02 +0000 (11:05 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 7 Dec 2012 11:05:02 +0000 (11:05 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/branches/ecore-1.7@80436 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

ChangeLog
NEWS
src/lib/ecore/ecore_main.c
src/lib/ecore/ecore_pipe.c
src/lib/ecore/ecore_private.h
src/lib/ecore_con/ecore_con_info.c
src/lib/ecore_file/ecore_file_monitor_inotify.c

index 2d8278e..0abbb0e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 2012-12-05  Robert David
 
        * Fix Ecore_Evas_Extn on Solaris 11.
+
+2012-12-07  Cedric Bail
+
+       * Don't leak fd on exec.
diff --git a/NEWS b/NEWS
index ed32364..145d9b6 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,15 @@
+Ecore 1.7.3
+
+Changes since Ecore 1.7.2:
+--------------------------
+
+Fixes:
+    * Fix small leak in Ecore Wayland.
+    * Fix Ecore_Evas_SDL resize bug.
+    * Fix Ecore_Evas_Extn build on Solaris 11.
+    * Fix Wayland support to latest API.
+    * Don't leak fd on exec.
+
 Ecore 1.7.2
 
 Changes since Ecore 1.7.1:
index fea9fa8..a3b4245 100644 (file)
@@ -262,6 +262,26 @@ static gboolean _ecore_glib_idle_enterer_called;
 static gboolean ecore_fds_ready;
 #endif
 
+Eina_Bool
+_ecore_fd_close_on_exec(int fd)
+{
+#ifdef HAVE_EXECVP
+   int flags;
+
+   flags = fcntl(fd, F_GETFD);
+   if (flags == -1)
+     return EINA_FALSE;
+
+   flags |= FD_CLOEXEC;
+   if (fcntl(fd, F_SETFD, flags) == -1)
+     return EINA_FALSE;
+   return EINA_TRUE;
+#else
+   (void) fd;
+   return EINA_FALSE;
+#endif
+}
+
 static inline void
 _ecore_fd_valid(void)
 {
@@ -746,6 +766,7 @@ _ecore_main_loop_init(void)
    if (epoll_fd < 0)
      WRN("Failed to create epoll fd!");
    epoll_pid = getpid();
+   _ecore_fd_close_on_exec(epoll_fd);
 
    /* add polls on all our file descriptors */
    Ecore_Fd_Handler *fdh;
@@ -781,6 +802,7 @@ _ecore_main_loop_init(void)
           WRN("failed to create timer fd!");
         else
           {
+             _ecore_fd_close_on_exec(timer_fd);
              ecore_timer_fd.fd = timer_fd;
              ecore_timer_fd.events = G_IO_IN;
              ecore_timer_fd.revents = 0;
index 6b24284..1f951b9 100644 (file)
@@ -147,6 +147,9 @@ ecore_pipe_add(Ecore_Pipe_Cb handler,
    p->handler = handler;
    p->data = data;
 
+   _ecore_fd_close_on_exec(fds[0]);
+   _ecore_fd_close_on_exec(fds[1]);
+
    fcntl(p->fd_read, F_SETFL, O_NONBLOCK);
    p->fd_handler = ecore_main_fd_handler_add(p->fd_read,
                                              ECORE_FD_READ,
index d812e3a..6c4543c 100644 (file)
@@ -172,6 +172,8 @@ void      *_ecore_event_signal_realtime_new(void);
 
 void      *_ecore_main_fd_handler_del(Ecore_Fd_Handler *fd_handler);
 
+Eina_Bool _ecore_fd_close_on_exec(int fd);
+
 void       _ecore_main_shutdown(void);
 
 #if defined (_WIN32) || defined (__lv2ppu__) || defined (HAVE_EXOTIC)
index a8f47bd..e3f35f0 100644 (file)
@@ -205,6 +205,26 @@ ecore_con_info_mcast_listen(Ecore_Con_Server *svr,
    return ecore_con_info_get(svr, done_cb, data, &hints);
 }
 
+Eina_Bool
+_ecore_fd_close_on_exec(int fd)
+{
+#ifdef HAVE_EXECVP
+   int flags;
+
+   flags = fcntl(fd, F_GETFD);
+   if (flags == -1)
+     return EINA_FALSE;
+
+   flags |= FD_CLOEXEC;
+   if (fcntl(fd, F_SETFD, flags) == -1)
+     return EINA_FALSE;
+   return EINA_TRUE;
+#else
+   (void) fd;
+   return EINA_FALSE;
+#endif
+}
+
 EAPI int
 ecore_con_info_get(Ecore_Con_Server *svr,
                    Ecore_Con_Info_Cb done_cb,
@@ -220,6 +240,9 @@ ecore_con_info_get(Ecore_Con_Server *svr,
         return 0;
      }
 
+   _ecore_fd_close_on_exec(fd[0]);
+   _ecore_fd_close_on_exec(fd[1]);
+
    cbdata = calloc(1, sizeof(CB_Data));
    if (!cbdata)
      {
index 30226d3..3e2392a 100644 (file)
@@ -7,6 +7,7 @@
 #include <string.h>
 #include <sys/types.h>
 #include <unistd.h>
+#include <fcntl.h>
 
 #include "ecore_file_private.h"
 
@@ -62,11 +63,20 @@ int
 ecore_file_monitor_inotify_init(void)
 {
    int fd;
+#ifdef HAVE_EXECVP
+   int flags;
+#endif
 
    fd = inotify_init();
    if (fd < 0)
      return 0;
 
+#ifdef HAVE_EXECVP
+   flags = fcntl(fd, F_GETFD);
+   flags |= FD_CLOEXEC;
+   fcntl(fd, F_SETFD, flags);
+#endif
+
    _fdh = ecore_main_fd_handler_add(fd, ECORE_FD_READ, _ecore_file_monitor_inotify_handler,
                                     NULL, NULL, NULL);
    if (!_fdh)