You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by GitBox <gi...@apache.org> on 2019/08/19 14:13:01 UTC

[GitHub] [incubator-brpc] liupengs opened a new pull request #893: fix bug: bthread_cond_timedwait not return when timeout

liupengs opened a new pull request #893: fix bug: bthread_cond_timedwait not return when timeout
URL: https://github.com/apache/incubator-brpc/pull/893
 
 
   修复 [issue886](https://github.com/apache/incubator-brpc/issues/866) 中 bthread_cond_timedwait  偶发超时后不退出的bug.
   
   **超时不退出的原因为:** 
   
   当设置的超时时间较短时可能会首先触发 erase_from_butex 函数去wake up 等待中的 bthread, 但是在此之前  wait_for_butex 函数还未被调用, 所以 此bthread 还未加入 waiters , 最终造成虽然设置了超时时间,但是 bthread_cond_timedwait 一直等待。
   
   **修复方式为:**
   
   向ButexWaiter 添加成员变量 start_erase_from_butex   用于标识 在执行函数 wait_for_butex 之前是否已经执行了函数 erase_from_butex。 另外添加原子变量 spin_lock 保护 start_erase_from_butex。
   
   由于我没有通读 bthread 的代码, 所以不能完全确认修复方式是否合理,请 @jamesge review 代码。

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org