Commit c36c0453 authored by Cedric Roux's avatar Cedric Roux

integration fix: fixes for pthread_getname_np

- define _GNU_SOURCE before including pthread.h
- do not use static for the array 'threadname' used
  to store the name, it makes it a global variable
  accessed by several threads in parallel
- increase size of 'threadname' (maybe not necessary)
- properly indent #define / #under (# should be at column 1)
parent a0325027
......@@ -28,6 +28,7 @@
*/
#define _GNU_SOURCE /* required for pthread_getname_np */
//#define LOG_TEST 1
#define COMPONENT_LOG
......@@ -1033,8 +1034,8 @@ void logRecord_mt(const char *file, const char *func, int line, int comp,
}
if ( (g_log->flag & FLAG_THREAD) || (c->flag & FLAG_THREAD) ) {
#define THREAD_NAME_LEN 16
static char threadname[THREAD_NAME_LEN];
# define THREAD_NAME_LEN 128
char threadname[THREAD_NAME_LEN];
if (pthread_getname_np(pthread_self(), threadname, THREAD_NAME_LEN) != 0)
{
perror("pthread_getname_np : ");
......@@ -1042,7 +1043,7 @@ void logRecord_mt(const char *file, const char *func, int line, int comp,
len += snprintf(&log_buffer[len], MAX_LOG_TOTAL - len, "[%s]", threadname);
if (len > MAX_LOG_TOTAL) len = MAX_LOG_TOTAL;
}
#undef THREAD_NAME_LEN
# undef THREAD_NAME_LEN
}
if ( (g_log->flag & FLAG_FUNCT) || (c->flag & FLAG_FUNCT) ) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment