HardySimpson/zlog

zlog is blocked at the `write()` system call, causing the program to hang.

forxn9 opened this issue · 2 comments

forxn9 commented

#define PRINT_INFO(fmt,...)
do{
zlog_info(zc,fmt,##VA_ARGS);
}while(0)

The program hangs during the use of zlog_info. By examining the stack with gdb, it is confirmed that the program is blocked at the write() system call. The detailed stack information is as follows:

bt.txt

forxn9 commented

For example, thread 4, after calling the zlog_rule_output_static_file_single function, remains blocked at the write function.
(gdb) thread 4
[Switching to thread 4 (Thread 0x7f8967d200 (LWP 6682))]
#0 0x0000007f8a8cea38 in write () from /lib/libpthread.so.0
(gdb) bt
#0 0x0000007f8a8cea38 in write () from /lib/libpthread.so.0
#1 0x0000007f8a88d864 in zlog_rule_output_static_file_single (
a_rule=0x1788eee0, a_thread=0x7f70000910) at rule.c:122
#2 0x0000007f8a889a84 in zlog_category_output (
a_category=a_category@entry=0x177aed20,
a_thread=a_thread@entry=0x7f70000910) at category.c:229
#3 0x0000007f8a894ab4 in zlog (category=0x177aed20,
file=0x41c4f0 "fj_gnss.c", filelen=9,
func=0x41ce38 <func.6343> "check_crc", funclen=9, line=1936, level=0,
format=0x41c8b0 "[gnss] crc check failed! 0x%08x 0x%08x buf=[%s]\n")
at zlog.c:860

forxn9 commented

a_rule->static_fd = open(a_rule->file_path, O_WRONLY | O_APPEND | O_CREAT | a_rule->file_open_flags, a_rule->file_perms);
此处对于文件的写入,是否可以直接添加 O_NONBLOCK进行非阻塞式写入
ping 各位大佬 @hydrogen18 @bmanojlovic @mofaph @pcorbes