update tlog
This commit is contained in:
13
src/tlog.c
13
src/tlog.c
@@ -504,9 +504,12 @@ static int _tlog_vprintf(struct tlog_log *log, vprint_callback print_callback, v
|
|||||||
if (len <= 0) {
|
if (len <= 0) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if (len >= log->max_line_size) {
|
} else if (len >= log->max_line_size) {
|
||||||
strncpy(buff, "[LOG TOO LONG, DISCARD]\n", sizeof(buff));
|
len = log->max_line_size;
|
||||||
buff[sizeof(buff) - 1] = '\0';
|
buff[len - 1] = '\0';
|
||||||
len = strnlen(buff, sizeof(buff));
|
buff[len - 2] = '\n';
|
||||||
|
buff[len - 3] = '.';
|
||||||
|
buff[len - 4] = '.';
|
||||||
|
buff[len - 5] = '.';
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_lock(&tlog.lock);
|
pthread_mutex_lock(&tlog.lock);
|
||||||
@@ -1834,6 +1837,7 @@ void tlog_exit(void)
|
|||||||
pthread_cond_signal(&tlog.cond);
|
pthread_cond_signal(&tlog.cond);
|
||||||
pthread_mutex_unlock(&tlog.lock);
|
pthread_mutex_unlock(&tlog.lock);
|
||||||
pthread_join(tlog.tid, &ret);
|
pthread_join(tlog.tid, &ret);
|
||||||
|
tlog.tid = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
tlog.root = NULL;
|
tlog.root = NULL;
|
||||||
@@ -1843,4 +1847,7 @@ void tlog_exit(void)
|
|||||||
|
|
||||||
pthread_cond_destroy(&tlog.cond);
|
pthread_cond_destroy(&tlog.cond);
|
||||||
pthread_mutex_destroy(&tlog.lock);
|
pthread_mutex_destroy(&tlog.lock);
|
||||||
|
|
||||||
|
tlog_format = NULL;
|
||||||
|
tlog.is_wait = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user