修复http api可能导致死锁的bug
Some checks failed
Android / build (push) Has been cancelled
CodeQL / Analyze (cpp) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Docker / build (push) Has been cancelled
Linux / build (push) Has been cancelled
macOS / build (push) Has been cancelled
Windows / build (push) Has been cancelled

This commit is contained in:
ziyuexiachu 2025-02-26 11:32:10 +08:00
parent cd7f7fb5ea
commit 52ca731392

View File

@ -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);
});
}