Skip to content

butex_wait超时无法唤醒 #617

@eddie74748

Description

@eddie74748

Describe the bug (描述bug)
bthread中调用butex_wait方法在参数abstime很小的情况下出现无法唤醒

To Reproduce (复现方法)
真实场景暂时无法复现,阅读代码中发现有这个可能,也通过手动改代码构造场景复现过

Expected behavior (期望行为)

Versions (各种版本)
OS: centos 7
Compiler:gcc 4.8
brpc: master
protobuf:2.4.1

Additional context/screenshots (更多上下文/截图)

在butex_wait方法中
https://github.com/brpc/brpc/blob/master/src/bthread/butex.cpp

code

代码641行中的erase_from_butex_and_wakeup有定时器在timer_thread中触发
代码655行中的wait_for_butex由下一个bthread在worker线程中调用

理论上来说,上述两个函数的执行时序没有办法保证的,
而如果erase_from_butex_and_wakeup在wait_for_butex前执行,那么调用butex_wait方法的bthread将永远无法唤醒。

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixNot belonging to other labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions