支持日志上下文

This commit is contained in:
xiongziliang
2023-11-20 21:59:43 +08:00
parent a13b8417e5
commit 8bd7157ca1
14 changed files with 32 additions and 20 deletions

View File

@@ -77,6 +77,7 @@ void WebRtcSession::onRecv_l(const char *data, size_t len) {
if (strong_server) {
auto session = static_pointer_cast<WebRtcSession>(strong_server->createSession(sock));
//2、创建新的WebRtcSession对象(绑定到WebRtcTransport所在线程)重新处理一遍ice binding request命令
Logger::setThreadContext(session);
session->onRecv_l(str.data(), str.size());
}
});
@@ -112,6 +113,7 @@ void WebRtcSession::onError(const SockException &err) {
auto transport = std::move(_transport);
getPoller()->async([transport, self]() mutable {
//延时减引用防止使用transport对象时销毁对象
Logger::setThreadContext(transport);
transport->removeTuple(self.get());
//确保transport在Session对象前销毁防止WebRtcTransport::onDestory()时获取不到Session对象
transport = nullptr;