-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
异步输出可能导致日志输出不完整 #48
Comments
取消 ELOG_ASSERT(init_ok); 断言,或者你还有其他什么解决思路吗? |
我现在就是删掉这里的断言解决的,这里应该也不需要断言的吧 |
或者就先改为下面方式吧,方便提个 pr 上来吗?
|
这种操作不行的。这样做,子线程就直接退出了,仍然会出现日志输出不完整的问题。这地方不需要对init_ok做判断,因为while循环里有sem_wait,如果没有内容需要输出,就自然等待了 |
已经提了一个PR给您 |
好的,感谢你的贡献哈~~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
EasyLogger/src/elog_async.c:
开启ELOG_ASYNC_OUTPUT_USING_PTHREAD情况下,主线程创建线程完成后,才将init_ok设置为true.如:
#ifdef ELOG_ASYNC_OUTPUT_USING_PTHREAD
pthread_attr_t thread_attr;
struct sched_param thread_sched_param;
#endif
//此时,子线程极有可能已经开始执行async_output,而在async_out一开始就断言init_ok为false,
如: ELOG_ASSERT(init_ok); 子程序就有可能再也没有机会执行后边的sem_wait了。
init_ok = true;
最后,只会输出 level < OUTPUT_LVL内容了。
The text was updated successfully, but these errors were encountered: