소스 검색

ignore events on non-initialised log

z3APA3A 5 년 전
부모
커밋
ca8788c65f
1개의 변경된 파일14개의 추가작업 그리고 4개의 파일을 삭제
  1. 14 4
      src/log.c

+ 14 - 4
src/log.c

@@ -137,10 +137,12 @@ static void delayflushlogs(void){
 
 
 void flushlogs(void){
-	struct logevent * evt;
-	evt = malloc(sizeof(struct logevent));
-	evt->event = FLUSH;
-	logpush(evt);
+	if(loginit){
+		struct logevent * evt;
+		evt = malloc(sizeof(struct logevent));
+		evt->event = FLUSH;
+		logpush(evt);
+	}
 }
 
 
@@ -290,6 +292,14 @@ void * logthreadfunc (void *p) {
 
 void logpush(struct logevent *evt){
 	pthread_mutex_lock(&log_mutex);
+	if(!loginit){
+		if(evt->event == FREEPARAM){
+			delayfreeparam(evt->param);
+		}
+		myfree(evt);
+		pthread_mutex_unlock(&log_mutex);
+		return;
+	}
 	if(logtail) logtail->next = evt;
 	logtail = evt;
 	evt->next = NULL;