mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-30 05:48:21 +08:00
修复http api可能导致死锁的bug
This commit is contained in:
@@ -293,12 +293,13 @@ static inline void addHttpListener(){
|
||||
};
|
||||
((HttpSession::HttpResponseInvoker &) invoker) = newInvoker;
|
||||
}
|
||||
|
||||
auto helper = static_cast<SocketHelper &>(sender).shared_from_this();
|
||||
// 在本poller线程下一次事件循环时执行http api,防止占用NoticeCenter的锁
|
||||
helper->getPoller()->async([it, parser, invoker, helper]() {
|
||||
try {
|
||||
it->second(parser, invoker, sender);
|
||||
it->second(parser, invoker, *helper);
|
||||
} catch (ApiRetException &ex) {
|
||||
responseApi(ex.code(), ex.what(), invoker);
|
||||
auto helper = static_cast<SocketHelper &>(sender).shared_from_this();
|
||||
helper->getPoller()->async([helper, ex]() { helper->shutdown(SockException(Err_shutdown, ex.what())); }, false);
|
||||
}
|
||||
#ifdef ENABLE_MYSQL
|
||||
@@ -309,6 +310,7 @@ static inline void addHttpListener(){
|
||||
catch (std::exception &ex) {
|
||||
responseApi(API::Exception, ex.what(), invoker);
|
||||
}
|
||||
},false);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user