From c8a20f85f6ee75bbd709982b7f0fe79bc188e683 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sun, 23 Apr 2023 00:10:18 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E6=89=93=E5=8D=B0SockExcepti?= =?UTF-8?q?on=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3rdpart/ZLToolKit | 2 +- server/WebApi.cpp | 4 ++-- server/WebHook.cpp | 2 +- src/Common/MultiMediaSourceMuxer.cpp | 2 +- src/Http/HlsPlayer.cpp | 2 +- src/Http/HttpSession.cpp | 5 +---- src/Rtmp/RtmpPlayer.cpp | 2 +- src/Rtp/RtpSender.cpp | 2 +- src/Rtp/RtpServer.cpp | 2 +- src/Rtp/RtpSession.cpp | 2 +- src/Shell/ShellSession.cpp | 2 +- srt/SrtSession.cpp | 2 +- tests/test_wsClient.cpp | 4 ++-- webrtc/WebRtcSession.cpp | 2 +- webrtc/WebRtcTransport.cpp | 2 +- 15 files changed, 17 insertions(+), 20 deletions(-) diff --git a/3rdpart/ZLToolKit b/3rdpart/ZLToolKit index 13371427..a73cda12 160000 --- a/3rdpart/ZLToolKit +++ b/3rdpart/ZLToolKit @@ -1 +1 @@ -Subproject commit 1337142746b84ef157a455aefcae5523baa22404 +Subproject commit a73cda127c221b788cc02db5ad98e49b0da56d52 diff --git a/server/WebApi.cpp b/server/WebApi.cpp index 33ca7ec7..aea85a6c 100755 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -966,7 +966,7 @@ void installWebApi() { //开始推流,如果推流失败或者推流中止,将会自动重试若干次,默认一直重试 pusher->setPushCallbackOnce([cb, key, url](const SockException &ex) { if (ex) { - WarnL << "Push " << url << " failed, key: " << key << ", err: " << ex.what(); + WarnL << "Push " << url << " failed, key: " << key << ", err: " << ex; lock_guard lck(s_proxyPusherMapMtx); s_proxyPusherMap.erase(key); } @@ -975,7 +975,7 @@ void installWebApi() { //被主动关闭推流 pusher->setOnClose([key, url](const SockException &ex) { - WarnL << "Push " << url << " failed, key: " << key << ", err: " << ex.what(); + WarnL << "Push " << url << " failed, key: " << key << ", err: " << ex; lock_guard lck(s_proxyPusherMapMtx); s_proxyPusherMap.erase(key); }); diff --git a/server/WebHook.cpp b/server/WebHook.cpp index 3df2807f..35c78957 100755 --- a/server/WebHook.cpp +++ b/server/WebHook.cpp @@ -96,7 +96,7 @@ static onceToken token([]() { static void parse_http_response(const SockException &ex, const Parser &res, const function &fun) { bool should_retry = true; if (ex) { - auto errStr = StrPrinter << "[network err]:" << ex.what() << endl; + auto errStr = StrPrinter << "[network err]:" << ex << endl; fun(Json::nullValue, errStr, should_retry); return; } diff --git a/src/Common/MultiMediaSourceMuxer.cpp b/src/Common/MultiMediaSourceMuxer.cpp index c88d3328..9c6f7a8a 100644 --- a/src/Common/MultiMediaSourceMuxer.cpp +++ b/src/Common/MultiMediaSourceMuxer.cpp @@ -266,7 +266,7 @@ void MultiMediaSourceMuxer::startSendRtp(MediaSource &sender, const MediaSourceE if (auto strong_self = weak_self.lock()) { // 可能归属线程发生变更 strong_self->getOwnerPoller(MediaSource::NullMediaSource())->async([=]() { - WarnL << "stream:" << strong_self->shortUrl() << " stop send rtp:" << ssrc << ", reason:" << ex.what(); + WarnL << "stream:" << strong_self->shortUrl() << " stop send rtp:" << ssrc << ", reason:" << ex; strong_self->_rtp_sender.erase(ssrc); NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastSendRtpStopped, *strong_self, ssrc, ex); }); diff --git a/src/Http/HlsPlayer.cpp b/src/Http/HlsPlayer.cpp index b87826c4..e8ca1471 100644 --- a/src/Http/HlsPlayer.cpp +++ b/src/Http/HlsPlayer.cpp @@ -118,7 +118,7 @@ void HlsPlayer::fetchSegment() { return; } if (err) { - WarnL << "Download ts segment " << url << " failed:" << err.what(); + WarnL << "Download ts segment " << url << " failed:" << err; if (err.getErrCode() == Err_timeout) { strong_self->_timeout_multiple = MAX(strong_self->_timeout_multiple + 1, MAX_TIMEOUT_MULTIPLE); }else{ diff --git a/src/Http/HttpSession.cpp b/src/Http/HttpSession.cpp index 80c70b6a..79924933 100644 --- a/src/Http/HttpSession.cpp +++ b/src/Http/HttpSession.cpp @@ -101,7 +101,7 @@ void HttpSession::onError(const SockException& err) { uint64_t duration = _ticker.createdTime() / 1000; WarnP(this) << "FLV/TS/FMP4播放器(" << _mediaInfo.shortUrl() - << ")断开:" << err.what() + << ")断开:" << err << ",耗时(s):" << duration; GET_CONFIG(uint32_t, iFlowThreshold, General::kFlowThreshold); @@ -111,9 +111,6 @@ void HttpSession::onError(const SockException& err) { } return; } - - //http客户端 - TraceP(this) << err.what(); } void HttpSession::onManager() { diff --git a/src/Rtmp/RtmpPlayer.cpp b/src/Rtmp/RtmpPlayer.cpp index 3630afe8..780ce980 100644 --- a/src/Rtmp/RtmpPlayer.cpp +++ b/src/Rtmp/RtmpPlayer.cpp @@ -101,7 +101,7 @@ void RtmpPlayer::onPlayResult_l(const SockException &ex, bool handshake_done) { return; } - WarnL << ex.getErrCode() << " " << ex.what(); + WarnL << ex.getErrCode() << " " << ex; if (!handshake_done) { //开始播放阶段 _play_timer.reset(); diff --git a/src/Rtp/RtpSender.cpp b/src/Rtp/RtpSender.cpp index de840633..a15884f0 100644 --- a/src/Rtp/RtpSender.cpp +++ b/src/Rtp/RtpSender.cpp @@ -336,7 +336,7 @@ void RtpSender::onFlushRtpList(shared_ptr > rtp_list) { void RtpSender::onErr(const SockException &ex) { _is_connect = false; - WarnL << "send rtp connection lost: " << ex.what(); + WarnL << "send rtp connection lost: " << ex; onClose(ex); } diff --git a/src/Rtp/RtpServer.cpp b/src/Rtp/RtpServer.cpp index d5af30ff..59e207ea 100644 --- a/src/Rtp/RtpServer.cpp +++ b/src/Rtp/RtpServer.cpp @@ -260,7 +260,7 @@ void RtpServer::connectToServer(const std::string &url, uint16_t port, const fun return; } if (err) { - WarnL << "连接到服务器 " << url << ":" << port << " 失败 " << err.what(); + WarnL << "连接到服务器 " << url << ":" << port << " 失败 " << err; } else { InfoL << "连接到服务器 " << url << ":" << port << " 成功"; strong_self->onConnect(); diff --git a/src/Rtp/RtpSession.cpp b/src/Rtp/RtpSession.cpp index 9c7e4357..26faadfb 100644 --- a/src/Rtp/RtpSession.cpp +++ b/src/Rtp/RtpSession.cpp @@ -60,7 +60,7 @@ void RtpSession::onRecv(const Buffer::Ptr &data) { } void RtpSession::onError(const SockException &err) { - WarnP(this) << _stream_id << " " << err.what(); + WarnP(this) << _stream_id << " " << err; } void RtpSession::onManager() { diff --git a/src/Shell/ShellSession.cpp b/src/Shell/ShellSession.cpp index 8f971749..81e18d7b 100644 --- a/src/Shell/ShellSession.cpp +++ b/src/Shell/ShellSession.cpp @@ -57,7 +57,7 @@ void ShellSession::onRecv(const Buffer::Ptr&buf) { } void ShellSession::onError(const SockException &err){ - WarnP(this) << err.what(); + WarnP(this) << err; } void ShellSession::onManager() { diff --git a/srt/SrtSession.cpp b/srt/SrtSession.cpp index 3bb3cfc4..5f73d92f 100644 --- a/srt/SrtSession.cpp +++ b/srt/SrtSession.cpp @@ -117,7 +117,7 @@ void SrtSession::onError(const SockException &err) { // udp链接超时,但是srt链接不一定超时,因为可能存在udp链接迁移的情况 //在udp链接迁移时,新的SrtSession对象将接管SrtSession对象的生命周期 //本SrtSession对象将在超时后自动销毁 - WarnP(this) << err.what(); + WarnP(this) << err; if (!_transport) { return; diff --git a/tests/test_wsClient.cpp b/tests/test_wsClient.cpp index fd70eb37..bd3ba0b5 100644 --- a/tests/test_wsClient.cpp +++ b/tests/test_wsClient.cpp @@ -33,7 +33,7 @@ protected: } //被动断开连接回调 void onErr(const SockException &ex) override { - WarnL << ex.what(); + WarnL << ex; } //tcp连接成功后每2秒触发一次该事件 void onManager() override { @@ -42,7 +42,7 @@ protected: } //连接服务器结果回调 void onConnect(const SockException &ex) override{ - DebugL << ex.what(); + DebugL << ex; } //数据全部发送完毕后回调 diff --git a/webrtc/WebRtcSession.cpp b/webrtc/WebRtcSession.cpp index d5012ef8..6216802c 100644 --- a/webrtc/WebRtcSession.cpp +++ b/webrtc/WebRtcSession.cpp @@ -103,7 +103,7 @@ void WebRtcSession::onError(const SockException &err) { //udp链接超时,但是rtc链接不一定超时,因为可能存在链接迁移的情况 //在udp链接迁移时,新的WebRtcSession对象将接管WebRtcTransport对象的生命周期 //本WebRtcSession对象将在超时后自动销毁 - WarnP(this) << err.what(); + WarnP(this) << err; if (!_transport) { return; diff --git a/webrtc/WebRtcTransport.cpp b/webrtc/WebRtcTransport.cpp index dae2f533..1d1431c9 100644 --- a/webrtc/WebRtcTransport.cpp +++ b/webrtc/WebRtcTransport.cpp @@ -1054,7 +1054,7 @@ void WebRtcTransportImp::onBeforeEncryptRtp(const char *buf, int &len, void *ctx } void WebRtcTransportImp::onShutdown(const SockException &ex) { - WarnL << ex.what(); + WarnL << ex; unrefSelf(); for (auto &tuple : _ice_server->GetTuples()) { tuple->shutdown(ex);