cdjingit opened a new issue #721: 一个被interrupt的bthread,总是sleep()成功,导致无法从sleep()退出. URL: https://github.com/apache/incubator-brpc/issues/721 **Describe the bug (描述bug)** 如下的bthread无法退出: 一个thread 周期性的发rpc,可能无法被stop后join。 原因是bthread_usleep永远成功。 ``` 1 void thread_hang() { 2 while(true) { 3 4 // Issue rpc. 5 channel.CallMethod(null, cntl, ....); 6 if (cntl.Failed()) { 7 .... 8 } 9 10 if (bthread_usleep() < 0) { 11 if (errno == ESTOP) { 12 break; 13 } 14 break; 15 } 16 } 17 } 18 19 20 void other_thread() { 21 bthread_start(&bth, thread_hang(),..); 22 23 ..... 24 25 bthread_stop(bth); 26 bthread_join(bth, nullptr); // Hang up here 27 } ``` **Expected behavior (期望行为)** 上面的形式的bthread不能够正常退出。目前的WA是通过bthread_stopped()来判断退出。 rpc的处理回复的流程Join(correlation_id) -> bthread_id_join() -> bthread::butex_wait()。在butex_wait()中会对于被interrupt的bthread会有如下操作: 标记bbw.task_meta->interrupted = false; 设置错误码为EINTR 而int TaskGroup::usleep(TaskGroup** pg, uint64_t timeout_us) 对于interrupted==false 直接返回成功,导致一个被interrupt的bthread总是sleep成功。
---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
