[vlc-commits] commit: Only print the first 5 threading errors each ( Rémi Denis-Courmont )
git at videolan.org
git at videolan.org
Mon Jun 7 19:58:36 CEST 2010
vlc/vlc-1.1 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Jun 7 20:53:18 2010 +0300| [6c9e62216b99c8b28ae3ec12a2637e14971d2b33] | committer: Rémi Denis-Courmont
Only print the first 5 threading errors each
(cherry picked from commit 2dde53c525ed5c9a8d74bb8a85e3ea8ead1dcd11)
Conflicts:
bin/override.c
> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.1.git/?a=commit;h=6c9e62216b99c8b28ae3ec12a2637e14971d2b33
---
bin/override.c | 33 ++++++++++++++++++++++-----------
1 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/bin/override.c b/bin/override.c
index e19ed2b..54ca687 100644
--- a/bin/override.c
+++ b/bin/override.c
@@ -23,6 +23,7 @@
#endif
#include <stdbool.h>
+#define MAX_ERRORS 5
void vlc_enable_override (void);
@@ -55,32 +56,37 @@ void vlc_enable_override (void)
pthread_atfork (NULL, NULL, vlc_reset_override);
}
-static void vlogbug (const char *level, const char *func, const char *fmt,
- va_list ap)
+static void vlogbug (unsigned *pc, const char *level, const char *func,
+ const char *fmt, va_list ap)
{
#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 (*pc < MAX_ERRORS)
+ {
+ (*pc)++;
+ 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
+ }
funlockfile (stderr);
}
-static void logbug (const char *level, const char *func, const char *fmt, ...)
+static void logbug (unsigned *pc, const char *level, const char *func,
+ const char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
- vlogbug (level, func, fmt, ap);
+ vlogbug (pc, level, func, fmt, ap);
va_end (ap);
}
@@ -96,7 +102,12 @@ static void *getsym (const char *name)
return sym;
}
-#define LOG(level, ...) logbug(level, __func__, __VA_ARGS__)
+#define LOG(level, ...) \
+ do { \
+ static unsigned counter = 0; \
+ logbug(&counter, level, __func__, __VA_ARGS__); \
+ } while (0)
+
#define CALL(func, ...) \
({ typeof (func) *sym = getsym ( # func); sym (__VA_ARGS__); })
More information about the vlc-commits
mailing list