Commit fa561475 authored by Haruki NAOI's avatar Haruki NAOI

fix some warnings.

parent c8bff02e
...@@ -516,9 +516,9 @@ int logInit (void) ...@@ -516,9 +516,9 @@ int logInit (void)
} }
extern int oai_exit; extern int oai_exit;
void * log_mem_write(void) void *log_mem_write(void *arg)
{ {
int *fp; int fp;
char f_name[1024]; char f_name[1024];
struct timespec slp_tm; struct timespec slp_tm;
slp_tm.tv_sec = 0; slp_tm.tv_sec = 0;
...@@ -540,7 +540,9 @@ void * log_mem_write(void) ...@@ -540,7 +540,9 @@ void * log_mem_write(void)
} }
snprintf(f_name,1024, "%s_%d.log",log_mem_filename,log_mem_file_cnt); snprintf(f_name,1024, "%s_%d.log",log_mem_filename,log_mem_file_cnt);
fp=open(f_name, O_WRONLY | O_CREAT, 0666); fp=open(f_name, O_WRONLY | O_CREAT, 0666);
write(fp, log_mem_d[log_mem_write_side].buf_p, log_mem_d[log_mem_write_side].buf_index); if(write(fp, log_mem_d[log_mem_write_side].buf_p, log_mem_d[log_mem_write_side].buf_index) < log_mem_d[log_mem_write_side].buf_index) {
// TODO assert ?
}
close(fp); close(fp);
log_mem_file_cnt++; log_mem_file_cnt++;
log_mem_d[log_mem_write_side].buf_index=0; log_mem_d[log_mem_write_side].buf_index=0;
...@@ -550,6 +552,7 @@ void * log_mem_write(void) ...@@ -550,6 +552,7 @@ void * log_mem_write(void)
nanosleep(&slp_tm,NULL); nanosleep(&slp_tm,NULL);
} }
} }
return 0;
} }
int logInit_log_mem (void) int logInit_log_mem (void)
...@@ -567,7 +570,7 @@ int logInit_log_mem (void) ...@@ -567,7 +570,7 @@ int logInit_log_mem (void)
if ((pthread_mutex_init (&log_mem_lock, NULL) != 0) if ((pthread_mutex_init (&log_mem_lock, NULL) != 0)
|| (pthread_cond_init (&log_mem_notify, NULL) != 0)) { || (pthread_cond_init (&log_mem_notify, NULL) != 0)) {
log_mem_d[1].enable_flag=0; log_mem_d[1].enable_flag=0;
return; return -1;
} }
pthread_create(&log_mem_thread, NULL, log_mem_write, (void*)NULL); pthread_create(&log_mem_thread, NULL, log_mem_write, (void*)NULL);
}else{ }else{
...@@ -1488,41 +1491,42 @@ void logRecord_mt(const char *file, const char *func, int line, int comp, ...@@ -1488,41 +1491,42 @@ void logRecord_mt(const char *file, const char *func, int line, int comp,
va_end(args); va_end(args);
// OAI printf compatibility // OAI printf compatibility
if ((g_log->onlinelog == 1) && (level != LOG_FILE)) if ((g_log->onlinelog == 1) && (level != LOG_FILE)) {
if(log_mem_flag==1){ if(log_mem_flag==1){
if(log_mem_d[log_mem_side].enable_flag==1){ if(log_mem_d[log_mem_side].enable_flag==1){
temp_index=log_mem_d[log_mem_side].buf_index; temp_index=log_mem_d[log_mem_side].buf_index;
if(temp_index+len+1 < LOG_MEM_SIZE){ if(temp_index+len+1 < LOG_MEM_SIZE){
log_mem_d[log_mem_side].buf_index+=len; log_mem_d[log_mem_side].buf_index+=len;
memcpy(&log_mem_d[log_mem_side].buf_p[temp_index],log_buffer,len); memcpy(&log_mem_d[log_mem_side].buf_p[temp_index],log_buffer,len);
}else{ }else{
log_mem_d[log_mem_side].enable_flag=0; log_mem_d[log_mem_side].enable_flag=0;
if(log_mem_d[1-log_mem_side].enable_flag==1){ if(log_mem_d[1-log_mem_side].enable_flag==1){
temp_index=log_mem_d[1-log_mem_side].buf_index; temp_index=log_mem_d[1-log_mem_side].buf_index;
if(temp_index+len+1 < LOG_MEM_SIZE){ if(temp_index+len+1 < LOG_MEM_SIZE){
log_mem_d[1-log_mem_side].buf_index+=len; log_mem_d[1-log_mem_side].buf_index+=len;
log_mem_side=1-log_mem_side; log_mem_side=1-log_mem_side;
memcpy(&log_mem_d[log_mem_side].buf_p[temp_index],log_buffer,len); memcpy(&log_mem_d[log_mem_side].buf_p[temp_index],log_buffer,len);
/* write down !*/ /* write down !*/
if (pthread_mutex_lock(&log_mem_lock) != 0) { if (pthread_mutex_lock(&log_mem_lock) != 0) {
return; return;
}
if(log_mem_write_flag==0){
log_mem_write_side=1-log_mem_side;
if(pthread_cond_signal(&log_mem_notify) != 0) {
} }
if(log_mem_write_flag==0){
log_mem_write_side=1-log_mem_side;
if(pthread_cond_signal(&log_mem_notify) != 0) {
}
}
if(pthread_mutex_unlock(&log_mem_lock) != 0) {
return;
}
}else{
log_mem_d[1-log_mem_side].enable_flag=0;
} }
if(pthread_mutex_unlock(&log_mem_lock) != 0) {
return;
}
}else{
log_mem_d[1-log_mem_side].enable_flag=0;
} }
} }
} }
}else{
fwrite(log_buffer, len, 1, stdout);
} }
}else{
fwrite(log_buffer, len, 1, stdout);
} }
if (g_log->syslog) { if (g_log->syslog) {
...@@ -1852,8 +1856,7 @@ void log_set_instance_type (log_instance_type_t instance) ...@@ -1852,8 +1856,7 @@ void log_set_instance_type (log_instance_type_t instance)
#endif #endif
void output_log_mem(void){ void output_log_mem(void){
int cnt,cnt2; int fp;
int *fp;
char f_name[1024]; char f_name[1024];
if(log_mem_flag==1){ if(log_mem_flag==1){
...@@ -1866,18 +1869,24 @@ void output_log_mem(void){ ...@@ -1866,18 +1869,24 @@ void output_log_mem(void){
if(log_mem_multi==1){ if(log_mem_multi==1){
snprintf(f_name,1024, "%s_%d.log",log_mem_filename,log_mem_file_cnt); snprintf(f_name,1024, "%s_%d.log",log_mem_filename,log_mem_file_cnt);
fp=open(f_name, O_WRONLY | O_CREAT, 0666); fp=open(f_name, O_WRONLY | O_CREAT, 0666);
write(fp, log_mem_d[0].buf_p, log_mem_d[0].buf_index); if(write(fp, log_mem_d[0].buf_p, log_mem_d[0].buf_index) < log_mem_d[0].buf_index) {
// TODO assert ?
}
close(fp); close(fp);
free(log_mem_d[0].buf_p); free(log_mem_d[0].buf_p);
snprintf(f_name,1024, "%s_%d.log",log_mem_filename,log_mem_file_cnt); snprintf(f_name,1024, "%s_%d.log",log_mem_filename,log_mem_file_cnt);
fp=open(f_name, O_WRONLY | O_CREAT, 0666); fp=open(f_name, O_WRONLY | O_CREAT, 0666);
write(fp, log_mem_d[1].buf_p, log_mem_d[1].buf_index); if(write(fp, log_mem_d[1].buf_p, log_mem_d[1].buf_index) < log_mem_d[1].buf_index) {
// TODO assert ?
}
close(fp); close(fp);
free(log_mem_d[1].buf_p); free(log_mem_d[1].buf_p);
}else{ }else{
fp=open(log_mem_filename, O_WRONLY | O_CREAT, 0666); fp=open(log_mem_filename, O_WRONLY | O_CREAT, 0666);
write(fp, log_mem_d[0].buf_p, log_mem_d[0].buf_index); if(write(fp, log_mem_d[0].buf_p, log_mem_d[0].buf_index) < log_mem_d[0].buf_index) {
// TODO assert ?
}
close(fp); close(fp);
free(log_mem_d[0].buf_p); free(log_mem_d[0].buf_p);
} }
......
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