[gimp] libgimpbase: fix declaration after statement and reset safecheck...



commit 49b4b1a5c2a4797f490a0e7e9eac1bcbb399a568
Author: Jehan <jehan girinstud io>
Date:   Mon Jun 25 01:04:01 2018 +0200

    libgimpbase: fix declaration after statement and reset safecheck...
    
    ... after each successful read().
    I completely missed this declaration after a statement during the review
    of !13 even though I saw another similar issue!
    
    Also let's reset the error counter to 0 each time a successful read()
    happens so that we can continue reading even if a lot of EINTR were to
    happen, as long as we globally go forward. Only consecutive errors
    increment the counter.
    
    Finally add a small comment to explain why we let EINTR pass instead of
    breaking directly.

 libgimpbase/gimputils.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/libgimpbase/gimputils.c b/libgimpbase/gimputils.c
index 8c7fa78a95..3e8cf0b0a8 100644
--- a/libgimpbase/gimputils.c
+++ b/libgimpbase/gimputils.c
@@ -1185,8 +1185,10 @@ gimp_stack_trace_print (const gchar   *prog_name,
   DWORD    tid = GetCurrentThreadId ();
 #elif defined(PLATFORM_OSX)
   uint64   tid64;
+  long     tid;
+
   pthread_threadid_np (NULL, &tid64);
-  long     tid = (long)tid64;
+  tid = (long) tid64;
 #elif defined(SYS_gettid)
   long     tid = syscall (SYS_gettid);
 #elif defined(HAVE_THR_SELF)
@@ -1284,6 +1286,13 @@ gimp_stack_trace_print (const gchar   *prog_name,
         {
           if (read_n < 0)
             {
+              /* LLDB on macOS seems to trigger a few EINTR error (see
+               * !13), though read() finally ends up working later. So
+               * let's not make this error fatal, and instead try again.
+               * Yet to avoid infinite loop (in case the error really
+               * happens at every call), we abandon after a few
+               * consecutive errors.
+               */
               if (errno == EINTR && eintr_count <= 5)
                 {
                   eintr_count++;
@@ -1291,6 +1300,7 @@ gimp_stack_trace_print (const gchar   *prog_name,
                 }
               break;
             }
+          eintr_count = 0;
           if (! stack_printed)
             {
 #if defined(G_OS_WIN32) || defined(SYS_gettid) || defined(HAVE_THR_SELF)


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