[Asterisk-cvs] asterisk logger.c,1.45,1.45.2.1
russell at lists.digium.com
russell at lists.digium.com
Tue Nov 2 21:01:17 CST 2004
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv30957
Modified Files:
Tag: v1-0
logger.c
Log Message:
Use getpid (non-linux) or gettid(linux) for thread identification (bug #2745)
Index: logger.c
===================================================================
RCS file: /usr/cvsroot/asterisk/logger.c,v
retrieving revision 1.45
retrieving revision 1.45.2.1
diff -u -d -r1.45 -r1.45.2.1
--- logger.c 28 Sep 2004 21:13:50 -0000 1.45
+++ logger.c 3 Nov 2004 02:03:43 -0000 1.45.2.1
@@ -48,6 +48,13 @@
#define MAX_MSG_QUEUE 200
+#ifdef __linux__
+#include <asm/unistd.h>
+#define GETTID() syscall(__NR_gettid)
+#else
+#define GETTID() getpid()
+#endif
+
static char dateformat[256] = "%b %e %T"; /* Original Asterisk Format */
AST_MUTEX_DEFINE_STATIC(msglist_lock);
AST_MUTEX_DEFINE_STATIC(loglock);
@@ -481,11 +488,11 @@
return;
}
if (level == __LOG_VERBOSE) {
- snprintf(buf, sizeof(buf), "VERBOSE[%ld]: ", (long)pthread_self());
+ snprintf(buf, sizeof(buf), "VERBOSE[%ld]: ", (long)GETTID());
level = __LOG_DEBUG;
} else {
snprintf(buf, sizeof(buf), "%s[%ld]: %s:%d in %s: ",
- levels[level], (long)pthread_self(), file, line, function);
+ levels[level], (long)GETTID(), file, line, function);
}
vsnprintf(buf+strlen(buf), sizeof(buf)-strlen(buf), fmt, args);
syslog(syslog_level_map[level], "%s", buf);
@@ -543,7 +550,7 @@
snprintf(buf, sizeof(buf), "%s %s[%ld]: %s:%s %s: ",
date,
term_color(tmp1, levels[level], colors[level], 0, sizeof(tmp1)),
- (long)pthread_self(),
+ (long)GETTID(),
term_color(tmp2, file, COLOR_BRWHITE, 0, sizeof(tmp2)),
term_color(tmp3, linestr, COLOR_BRWHITE, 0, sizeof(tmp3)),
term_color(tmp4, function, COLOR_BRWHITE, 0, sizeof(tmp4)));
@@ -556,7 +563,7 @@
}
} else if ((chan->logmask & (1 << level)) && (chan->fileptr)) {
snprintf(buf, sizeof(buf), "%s %s[%ld]: ", date,
- levels[level], (long)pthread_self());
+ levels[level], (long)GETTID());
fprintf(chan->fileptr, buf);
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
More information about the svn-commits
mailing list