stepinto commented on issue #2278:
URL: https://github.com/apache/brpc/issues/2278#issuecomment-1596368417
> 这里是因为什么需要在catch里切bthread呢,能换一种实现方式么
如果发现了这个问题,可以换一种写法。比如让 `catch {...}` 块中的代码短一点,或者 `catch (const Exception &e)`
改为 `catch (Exception e)` 让异常拷贝一下。
这个问题的危险在于难以被发现。bthread 切换行为会传染。例如 `foo()` 中 `catch {...}` 调用了
`bar()`,`bar()` 调用了 `baz()`,`baz()` 调用了 `bthread_mutex()`。这些
`foo()`、`bar()`、`baz()` 是不同的人在不同时期写的。`foo()` 的作者只要在 `catch { ... }`
做点复杂的事,就难以避免不被切换出去。
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]