修复mbtk_logd进程 read log_radio buffer 节点大小,新增日志落盘功能

Change-Id: I3f1a1d148be26bad19b2e66b0ca7536df1e9c483
diff --git a/mbtk/mbtk_logd/main.c b/mbtk/mbtk_logd/main.c
index 5dde3b8..a4fb7f3 100755
--- a/mbtk/mbtk_logd/main.c
+++ b/mbtk/mbtk_logd/main.c
@@ -20,12 +20,47 @@
 #include "mbtk_type.h"
 //#define DEBUG 1
 
+#include <signal.h>
+
 #ifdef DEBUG
 #define mbtk_log(...)                    printf(__VA_ARGS__)
 #else
 #define mbtk_log(...)
 #endif
 
+
+#define    MAX_BUFFER_SIZE (8*1024)
+
+int tmp_syslog_fd = -1;
+int tmp_rd_fd = -1;
+
+char syslog_buff[MAX_BUFFER_SIZE] = {0};
+char radiolog_buff[MAX_BUFFER_SIZE] = {0};
+
+
+static void signal_handler(int signum)
+{
+    printf("Received SIGTERM signal, fflush buffer");
+    if(fcntl(tmp_syslog_fd, F_GETFL) != -1 && strlen(syslog_buff) > 0)
+    {
+        if(write(tmp_syslog_fd, syslog_buff, strlen(syslog_buff)) < 0) 
+        {
+            perror("write error");
+        }
+        memset(syslog_buff,0,MAX_BUFFER_SIZE);
+    }
+    
+    if(fcntl(tmp_rd_fd, F_GETFL) != -1 && strlen(radiolog_buff) > 0)
+    {
+        if(write(tmp_rd_fd, radiolog_buff, strlen(radiolog_buff)) < 0) 
+        {
+            perror("write error");
+        }
+        memset(radiolog_buff,0,MAX_BUFFER_SIZE);
+    }
+    
+}
+
 static void handler_free(log_config_entry* listdata)
 {
     int i, n;
@@ -232,8 +267,9 @@
     pthread_t pid[5] = {0};
     int i, ret;
     void* tret;
-//    struct filter_list_t* _filter_list = NULL;
+    //struct filter_list_t* _filter_list = NULL;
 
+    signal(SIGTERM, signal_handler);
 #ifdef MBTK_DUMP_SUPPORT
     mbtk_debug_open(NULL, TRUE);
 #endif