]> granicus.if.org Git - gc/commitdiff
Remove abort on open log failure from GC_write (Win32)
authorIvan Maidanski <ivmai@mail.ru>
Mon, 10 Dec 2012 04:40:19 +0000 (08:40 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 10 Dec 2012 14:40:50 +0000 (18:40 +0400)
* misc.c (GC_write): Do not abort (unconditionally) if
GC_CreateLogFile failed, return -1 (or, even, 0 if NO_DEBUGGING)
instead; update comment (Win32 only).

misc.c

diff --git a/misc.c b/misc.c
index aabda705408dd2435d0346b2c727bab45774c512..d22ed6ea29d058e9d0f92d050b30b61b5135311b 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -1345,8 +1345,7 @@ GC_API void GC_CALL GC_enable_incremental(void)
   {
       BOOL res;
       DWORD written;
-#     if (defined(THREADS) && defined(GC_ASSERTIONS)) \
-         || !defined(GC_PRINT_VERBOSE_STATS)
+#     if defined(THREADS) && defined(GC_ASSERTIONS)
         static GC_bool inside_write = FALSE;
                         /* to prevent infinite recursion at abort.      */
         if (inside_write)
@@ -1362,18 +1361,17 @@ GC_API void GC_CALL GC_enable_incremental(void)
           ABORT("Assertion failure: GC_write called with write_disabled");
         }
 #     endif
+      if (GC_log == 0) {
+        GC_log = GC_CreateLogFile();
+      }
       if (GC_log == INVALID_HANDLE_VALUE) {
-          IF_NEED_TO_LOCK(LeaveCriticalSection(&GC_write_cs));
+        IF_NEED_TO_LOCK(LeaveCriticalSection(&GC_write_cs));
+#       ifdef NO_DEBUGGING
+          /* Ignore open log failure (e.g., it might be caused by       */
+          /* read-only folder of the client application).               */
+          return 0;
+#       else
           return -1;
-      } else if (GC_log == 0) {
-        GC_log = GC_CreateLogFile();
-        /* Ignore open log failure if the collector is built with       */
-        /* print_stats always set on.                                   */
-#       ifndef GC_PRINT_VERBOSE_STATS
-          if (GC_log == INVALID_HANDLE_VALUE) {
-            inside_write = TRUE;
-            ABORT("Open of log file failed");
-          }
 #       endif
       }
       res = WriteFile(GC_log, buf, (DWORD)len, &written, NULL);