mirror of
https://gitee.com/xia-chu/ZLMediaKit.git
synced 2026-05-19 16:27:50 +08:00
修复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
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:
parent
cd7f7fb5ea
commit
52ca731392
@ -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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user