[evolution-data-server/gnome-3-22] camel-stream-process: Avoid call of g_debug() in the fork process



commit 7a33e8b171854adf2a79811106584103a81eee7d
Author: Milan Crha <mcrha redhat com>
Date:   Mon Jan 2 16:16:27 2017 +0100

    camel-stream-process: Avoid call of g_debug() in the fork process
    
    The call to g_debug(), and eventually also g_strerror() in the fork
    process could cause deadlocks on mutexes in GLib in certain situations,
    thus rather do not call it at all.

 camel/camel-stream-process.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/camel/camel-stream-process.c b/camel/camel-stream-process.c
index fd3f7c7..11dd53e 100644
--- a/camel/camel-stream-process.c
+++ b/camel/camel-stream-process.c
@@ -40,12 +40,6 @@
 #include "camel-file-utils.h"
 #include "camel-stream-process.h"
 
-#define CHECK_CALL(x) G_STMT_START { \
-       if ((x) == -1) { \
-               g_debug ("%s: Call of '" #x "' failed: %s", G_STRFUNC, g_strerror (errno)); \
-       } \
-       } G_STMT_END
-
 extern gint camel_verbose_debug;
 
 G_DEFINE_TYPE (CamelStreamProcess, camel_stream_process, CAMEL_TYPE_STREAM)
@@ -211,7 +205,13 @@ do_exec_command (gint fd,
 
        maxopen = sysconf (_SC_OPEN_MAX);
        for (i = 3; i < maxopen; i++) {
-               CHECK_CALL (fcntl (i, F_SETFD, FD_CLOEXEC));
+               if (fcntl (i, F_SETFD, FD_CLOEXEC) == -1 && errno != EBADF) {
+                       /* Would g_debug() this, but it can cause deadlock on mutexes
+                          in GLib in certain situations, thus rather ignore it at all.
+                          It's also quite likely, definitely in the early stage, that
+                          most of the file descriptors are not valid anyway. */
+                       /* g_debug ("%s: Call of 'fcntl (%d, F_SETFD, FD_CLOEXEC)' failed: %s", G_STRFUNC, i, 
g_strerror (errno)); */
+               }
        }
 
        setsid ();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]