LOG: do not depend on oai_exit
By using oai_exit in log.c, LOG depends on being compiled into an executable that defines such symbol, which is not always the case (nor does it make sense). oai_exit is only used in a loop to optionally write out memory. The loop could relatively easily be aborted by setting a variable:
This commit is contained in:
@@ -45,6 +45,7 @@
|
|||||||
#include "common/config/config_userapi.h"
|
#include "common/config/config_userapi.h"
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include <stdatomic.h>
|
||||||
#include "common/utils/LOG/log_extern.h"
|
#include "common/utils/LOG/log_extern.h"
|
||||||
|
|
||||||
// main log variables
|
// main log variables
|
||||||
@@ -810,7 +811,7 @@ void logClean (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int oai_exit;
|
static atomic_bool stop_flush_mem_to_file = false;
|
||||||
void flush_mem_to_file(void)
|
void flush_mem_to_file(void)
|
||||||
{
|
{
|
||||||
int fp;
|
int fp;
|
||||||
@@ -821,7 +822,7 @@ void flush_mem_to_file(void)
|
|||||||
|
|
||||||
pthread_setname_np( pthread_self(), "flush_mem_to_file");
|
pthread_setname_np( pthread_self(), "flush_mem_to_file");
|
||||||
|
|
||||||
while (!oai_exit) {
|
while (!atomic_load(&stop_flush_mem_to_file)) {
|
||||||
pthread_mutex_lock(&log_mem_lock);
|
pthread_mutex_lock(&log_mem_lock);
|
||||||
log_mem_write_flag=0;
|
log_mem_write_flag=0;
|
||||||
pthread_cond_wait(&log_mem_notify, &log_mem_lock);
|
pthread_cond_wait(&log_mem_notify, &log_mem_lock);
|
||||||
@@ -981,6 +982,7 @@ void close_log_mem(void){
|
|||||||
char f_name[1024];
|
char f_name[1024];
|
||||||
|
|
||||||
if(log_mem_flag==1){
|
if(log_mem_flag==1){
|
||||||
|
atomic_store(&stop_flush_mem_to_file, false);
|
||||||
log_mem_d[0].enable_flag=0;
|
log_mem_d[0].enable_flag=0;
|
||||||
log_mem_d[1].enable_flag=0;
|
log_mem_d[1].enable_flag=0;
|
||||||
usleep(10); // wait for log writing
|
usleep(10); // wait for log writing
|
||||||
|
|||||||
Reference in New Issue
Block a user