Session类构造析构跟踪日志统一在底层网络框架打印

This commit is contained in:
xiongziliang 2023-04-22 23:30:22 +08:00
parent f1037e3767
commit de8249592e
9 changed files with 9 additions and 28 deletions

@ -1 +1 @@
Subproject commit ad7ad8620eb18e94afcf3e6f2df15ebcc845b502 Subproject commit 1337142746b84ef157a455aefcae5523baa22404

View File

@ -24,14 +24,11 @@ using namespace toolkit;
namespace mediakit { namespace mediakit {
HttpSession::HttpSession(const Socket::Ptr &pSock) : Session(pSock) { HttpSession::HttpSession(const Socket::Ptr &pSock) : Session(pSock) {
TraceP(this);
GET_CONFIG(uint32_t,keep_alive_sec,Http::kKeepAliveSecond); GET_CONFIG(uint32_t,keep_alive_sec,Http::kKeepAliveSecond);
pSock->setSendTimeOutSecond(keep_alive_sec); pSock->setSendTimeOutSecond(keep_alive_sec);
} }
HttpSession::~HttpSession() { HttpSession::~HttpSession() = default;
TraceP(this);
}
void HttpSession::Handle_Req_HEAD(ssize_t &content_len){ void HttpSession::Handle_Req_HEAD(ssize_t &content_len){
//暂时全部返回200 OK因为HTTP GET存在按需生成流的操作所以不能按照HTTP GET的流程返回 //暂时全部返回200 OK因为HTTP GET存在按需生成流的操作所以不能按照HTTP GET的流程返回

View File

@ -18,14 +18,11 @@ using namespace toolkit;
namespace mediakit { namespace mediakit {
RtmpSession::RtmpSession(const Socket::Ptr &sock) : Session(sock) { RtmpSession::RtmpSession(const Socket::Ptr &sock) : Session(sock) {
DebugP(this);
GET_CONFIG(uint32_t,keep_alive_sec,Rtmp::kKeepAliveSecond); GET_CONFIG(uint32_t,keep_alive_sec,Rtmp::kKeepAliveSecond);
sock->setSendTimeOutSecond(keep_alive_sec); sock->setSendTimeOutSecond(keep_alive_sec);
} }
RtmpSession::~RtmpSession() { RtmpSession::~RtmpSession() = default;
DebugP(this);
}
void RtmpSession::onError(const SockException& err) { void RtmpSession::onError(const SockException& err) {
bool is_player = !_push_src_ownership; bool is_player = !_push_src_ownership;

View File

@ -36,7 +36,6 @@ void RtpSession::setParams(mINI &ini) {
} }
RtpSession::RtpSession(const Socket::Ptr &sock) : Session(sock) { RtpSession::RtpSession(const Socket::Ptr &sock) : Session(sock) {
DebugP(this);
socklen_t addr_len = sizeof(_addr); socklen_t addr_len = sizeof(_addr);
getpeername(sock->rawFD(), (struct sockaddr *)&_addr, &addr_len); getpeername(sock->rawFD(), (struct sockaddr *)&_addr, &addr_len);
_is_udp = sock->sockType() == SockNum::Sock_UDP; _is_udp = sock->sockType() == SockNum::Sock_UDP;
@ -47,7 +46,6 @@ RtpSession::RtpSession(const Socket::Ptr &sock) : Session(sock) {
} }
RtpSession::~RtpSession() { RtpSession::~RtpSession() {
DebugP(this);
if(_process){ if(_process){
RtpSelector::Instance().delProcess(_stream_id,_process.get()); RtpSelector::Instance().delProcess(_stream_id,_process.get());
} }

View File

@ -52,14 +52,11 @@ static unordered_map<string, weak_ptr<RtspSession> > g_mapGetter;
static recursive_mutex g_mtxGetter; static recursive_mutex g_mtxGetter;
RtspSession::RtspSession(const Socket::Ptr &sock) : Session(sock) { RtspSession::RtspSession(const Socket::Ptr &sock) : Session(sock) {
DebugP(this);
GET_CONFIG(uint32_t,keep_alive_sec,Rtsp::kKeepAliveSecond); GET_CONFIG(uint32_t,keep_alive_sec,Rtsp::kKeepAliveSecond);
sock->setSendTimeOutSecond(keep_alive_sec); sock->setSendTimeOutSecond(keep_alive_sec);
} }
RtspSession::~RtspSession() { RtspSession::~RtspSession() = default;
DebugP(this);
}
void RtspSession::onError(const SockException &err) { void RtspSession::onError(const SockException &err) {
bool is_player = !_push_src_ownership; bool is_player = !_push_src_ownership;
@ -405,7 +402,6 @@ void RtspSession::handleReq_Describe(const Parser &parser) {
} }
void RtspSession::onAuthSuccess() { void RtspSession::onAuthSuccess() {
TraceP(this);
weak_ptr<RtspSession> weak_self = dynamic_pointer_cast<RtspSession>(shared_from_this()); weak_ptr<RtspSession> weak_self = dynamic_pointer_cast<RtspSession>(shared_from_this());
MediaSource::findAsync(_media_info, weak_self.lock(), [weak_self](const MediaSource::Ptr &src){ MediaSource::findAsync(_media_info, weak_self.lock(), [weak_self](const MediaSource::Ptr &src){
auto strong_self = weak_self.lock(); auto strong_self = weak_self.lock();

View File

@ -25,13 +25,10 @@ static onceToken s_token([]() {
}, nullptr); }, nullptr);
ShellSession::ShellSession(const Socket::Ptr &_sock) : Session(_sock) { ShellSession::ShellSession(const Socket::Ptr &_sock) : Session(_sock) {
DebugP(this);
pleaseInputUser(); pleaseInputUser();
} }
ShellSession::~ShellSession() { ShellSession::~ShellSession() = default;
DebugP(this);
}
void ShellSession::onRecv(const Buffer::Ptr&buf) { void ShellSession::onRecv(const Buffer::Ptr&buf) {
//DebugL << hexdump(buf->data(), buf->size()); //DebugL << hexdump(buf->data(), buf->size());

View File

@ -16,9 +16,7 @@ SrtSession::SrtSession(const Socket::Ptr &sock)
// TraceL<<"after addr len "<<addr_len<<" family "<<_peer_addr.ss_family; // TraceL<<"after addr len "<<addr_len<<" family "<<_peer_addr.ss_family;
} }
SrtSession::~SrtSession() { SrtSession::~SrtSession() = default;
InfoP(this);
}
EventPoller::Ptr SrtSession::queryPoller(const Buffer::Ptr &buffer) { EventPoller::Ptr SrtSession::queryPoller(const Buffer::Ptr &buffer) {
uint8_t *data = (uint8_t *)buffer->data(); uint8_t *data = (uint8_t *)buffer->data();

View File

@ -6,10 +6,10 @@
namespace SRT { namespace SRT {
SrtTransportImp::SrtTransportImp(const EventPoller::Ptr &poller) SrtTransportImp::SrtTransportImp(const EventPoller::Ptr &poller)
: SrtTransport(poller) {} : SrtTransport(poller) {
}
SrtTransportImp::~SrtTransportImp() { SrtTransportImp::~SrtTransportImp() {
InfoP(this);
uint64_t duration = _alive_ticker.createdTime() / 1000; uint64_t duration = _alive_ticker.createdTime() / 1000;
WarnP(this) << (_is_pusher ? "srt 推流器(" : "srt 播放器(") << _media_info.shortUrl() << ")断开,耗时(s):" << duration; WarnP(this) << (_is_pusher ? "srt 推流器(" : "srt 播放器(") << _media_info.shortUrl() << ")断开,耗时(s):" << duration;

View File

@ -51,9 +51,7 @@ WebRtcSession::WebRtcSession(const Socket::Ptr &sock) : Session(sock) {
_over_tcp = sock->sockType() == SockNum::Sock_TCP; _over_tcp = sock->sockType() == SockNum::Sock_TCP;
} }
WebRtcSession::~WebRtcSession() { WebRtcSession::~WebRtcSession() = default;
InfoP(this);
}
void WebRtcSession::attachServer(const Server &server) { void WebRtcSession::attachServer(const Server &server) {
_server = std::dynamic_pointer_cast<toolkit::TcpServer>(const_cast<Server &>(server).shared_from_this()); _server = std::dynamic_pointer_cast<toolkit::TcpServer>(const_cast<Server &>(server).shared_from_this());