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