Fix bthread_usleep return unexpected error #2511
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
Issue Number:
Problem Summary:
#2435 的改动可能会导致bthread_usleep实际上成功执行,但是返回ESTOP失败。
_add_sleep_event
函数中,在定时器添加成功后,e.meta->current_sleep = sleep_id
之前,定时器执行,唤醒了协程。brpc/src/bthread/task_group.cpp
Lines 757 to 775 in 09141d4
协程被唤醒后,
current_sleep
为0、interrupted
为false,返回了ESTOP错误。brpc/src/bthread/task_group.cpp
Lines 804 to 808 in 09141d4
What is changed and the side effects?
Changed:
使用一个特定的成员变量代替
current_sleep==0
来表示定时器添加失败。Side effects:
Performance effects(性能影响):
Breaking backward compatibility(向后兼容性):
Check List: