switch_log.patch
1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
--- freeswitch-1.0.6/src/switch_log.c 2010-04-07 02:05:28.000000000 +0800
+++ freeswitch-1.0.6/src/switch_log.c 2012-12-19 17:51:18.000000000 +0800
@@ -30,6 +30,8 @@
*
*/
+#include <linux/unistd.h>
+
#include <switch.h>
#include "private/switch_core_pvt.h"
@@ -280,23 +282,22 @@
static void *SWITCH_THREAD_FUNC log_thread(switch_thread_t *t, void *obj)
{
-
+ void *pop = NULL;
if (!obj) {
obj = NULL;
}
THREAD_RUNNING = 1;
while (THREAD_RUNNING == 1) {
- void *pop = NULL;
switch_log_node_t *node = NULL;
switch_log_binding_t *binding;
if (switch_queue_pop(LOG_QUEUE, &pop) != SWITCH_STATUS_SUCCESS) {
- break;
+ continue;
}
if (!pop) {
- break;
+ continue;
}
node = (switch_log_node_t *) pop;
@@ -311,7 +312,15 @@
switch_log_node_free(&node);
}
-
+
+ //chenyuzhen add to flush all log node
+ while(switch_queue_trypop(LOG_QUEUE,&pop) == SWITCH_STATUS_SUCCESS){
+ if(pop){
+ switch_log_node_t *node=(switch_log_node_t*)pop;
+ switch_log_node_free(&node);
+ }
+ }
+
THREAD_RUNNING = 0;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Logger Ended.\n");
return NULL;
@@ -376,8 +385,8 @@
switch_time_exp_t tm;
switch_time_exp_lt(&tm, now);
- switch_snprintf(date, sizeof(date), "%0.4d-%0.2d-%0.2d %0.2d:%0.2d:%0.2d.%0.6d",
- tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_usec);
+ switch_snprintf(date, sizeof(date), "%0.4d-%0.2d-%0.2d %0.2d:%0.2d:%0.2d.%0.6d {%d}",
+ tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_usec,syscall(__NR_gettid));
//switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);