[vlc-commits] commit: Only print the 20 first threading errors ( Rémi Denis-Courmont )

git at videolan.org git at videolan.org
Mon Jun 7 19:43:08 CEST 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Jun  7 20:42:49 2010 +0300| [d5119bb3f582d9e6899d7bc953cc5714cc8cafa6] | committer: Rémi Denis-Courmont 

Only print the 20 first threading errors

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d5119bb3f582d9e6899d7bc953cc5714cc8cafa6
---

 bin/override.c |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/bin/override.c b/bin/override.c
index b5de22d..4f39587 100644
--- a/bin/override.c
+++ b/bin/override.c
@@ -23,6 +23,7 @@
 #endif
 
 #include <stdbool.h>
+#define MAX_ERRORS 20
 
 void vlc_enable_override (void);
 
@@ -59,20 +60,26 @@ void vlc_enable_override (void)
 static void vlogbug (const char *level, const char *func, const char *fmt,
                      va_list ap)
 {
+    static unsigned counter = 0;
 #ifdef HAVE_BACKTRACE
-    const size_t framec = 4;
+    const size_t framec = 5;
     void *framev[framec];
 
     backtrace (framev, framec);
 #endif
     flockfile (stderr);
-    fprintf (stderr, "%s: call to %s(", level, func);
-    vfprintf (stderr, fmt, ap);
-    fputs (")\n", stderr);
-    fflush (stderr);
+    if (counter < MAX_ERRORS)
+    {
+        fprintf (stderr, "%s: call to %s(", level, func);
+        vfprintf (stderr, fmt, ap);
+        fputs (")\n", stderr);
+        fflush (stderr);
 #ifdef HAVE_BACKTRACE
-    backtrace_symbols_fd (framev + 2, framec - 2, fileno (stderr));
+        backtrace_symbols_fd (framev + 2, framec - 2, fileno (stderr));
 #endif
+        if (++counter == MAX_ERRORS)
+            fprintf (stderr, "Too many errors. Not logging anymore.\n");
+    }
     funlockfile (stderr);
 }
 



More information about the vlc-commits mailing list