先判断buf中是否有数据,再进行上锁-输出-解锁的操作,避免buf为空时的频繁上/解锁操作

pull/81/head
book诗意 5 years ago committed by GitHub
parent fd21dfe753
commit a29872cc71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -82,6 +82,7 @@ void elog_buf_output(const char *log, size_t size) {
* flush all buffered logs to output device * flush all buffered logs to output device
*/ */
void elog_flush(void) { void elog_flush(void) {
if(buf_write_size){
/* lock output */ /* lock output */
elog_output_lock(); elog_output_lock();
/* output log */ /* output log */
@ -91,6 +92,7 @@ void elog_flush(void) {
/* unlock output */ /* unlock output */
elog_output_unlock(); elog_output_unlock();
} }
}
/** /**
* enable or disable buffered output mode * enable or disable buffered output mode

Loading…
Cancel
Save