修复日志落盘可能log重复写入文件的问题
Change-Id: I927f6c0b023eefb2b85d58a93ec2b01bdcd46f99
diff --git a/mbtk/mbtk_logd/main.c b/mbtk/mbtk_logd/main.c
index 71bc1f6..4cd4888 100755
--- a/mbtk/mbtk_logd/main.c
+++ b/mbtk/mbtk_logd/main.c
@@ -38,29 +38,40 @@
int tmp_syslog_fd = -1;
int tmp_rd_fd = -1;
-char syslog_buff[MAX_BUFFER_SIZE] = {0};
-char radiolog_buff[MAX_BUFFER_SIZE] = {0};
+//char syslog_buff[MAX_BUFFER_SIZE] = {0};
+//char radiolog_buff[MAX_BUFFER_SIZE] = {0};
+char *radio_globalPtr = NULL;
+char *sys_globalPtr = NULL;
+
+int radio_len = 0;
+int sys_len = 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(fcntl(tmp_syslog_fd, F_GETFL) != -1 && sys_globalPtr !=NULL )
{
- if(write(tmp_syslog_fd, syslog_buff, strlen(syslog_buff)) < 0)
+ if(write(tmp_syslog_fd, sys_globalPtr, sys_len) < 0)
{
perror("write error");
}
- memset(syslog_buff,0,MAX_BUFFER_SIZE);
+ // memset(syslog_buff,0,MAX_BUFFER_SIZE);
+ memset(sys_globalPtr, 0, MAX_BUFFER_SIZE);
+ sys_globalPtr =NULL;
}
- if(fcntl(tmp_rd_fd, F_GETFL) != -1 && strlen(radiolog_buff) > 0)
+ if(fcntl(tmp_rd_fd, F_GETFL) != -1 && radio_globalPtr !=NULL)
{
- if(write(tmp_rd_fd, radiolog_buff, strlen(radiolog_buff)) < 0)
+ if(write(tmp_rd_fd, radio_globalPtr, radio_len) < 0)
{
perror("write error");
}
- memset(radiolog_buff,0,MAX_BUFFER_SIZE);
+
+ //memset(radiolog_buff,0,MAX_BUFFER_SIZE);
+ memset(radio_globalPtr, 0, MAX_BUFFER_SIZE);
+ radio_globalPtr =NULL;
+
}
}