From 32bb96a5c2787d2775ba541644fd23f602853f26 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 3 Feb 2022 15:16:52 +0800 Subject: [PATCH] Squash: Fix bugs --- README.md | 1 + trunk/conf/docker.conf | 2 ++ trunk/doc/CHANGELOG.md | 4 ++++ trunk/research/console/js/srs.console.js | 6 +++++- trunk/src/core/srs_core_version4.hpp | 2 +- trunk/src/srt/srt_conn.cpp | 9 ++++++++- trunk/src/srt/srt_conn.hpp | 2 ++ trunk/src/srt/srt_handle.cpp | 13 +++++++++++++ 8 files changed, 36 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4ae3e549e..f861dbcff 100755 --- a/README.md +++ b/README.md @@ -134,6 +134,7 @@ We are grateful to the community for contributing bugfix and improvements, pleas ## Releases +* 2022-01-30, Release [v4.0-b5](https://github.com/ossrs/srs/releases/tag/v4.0-b5), v4.0-b5, 4.0 beta5, v4.0.236, 144416 lines. * 2022-01-17, Release [v4.0-b4](https://github.com/ossrs/srs/releases/tag/v4.0-b4), v4.0-b4, 4.0 beta4, v4.0.230, 144393 lines. * 2022-01-13, Release [v4.0-b3](https://github.com/ossrs/srs/releases/tag/v4.0-b3), v4.0-b3, 4.0 beta3, v4.0.229, 144393 lines. * 2022-01-03, Release [v4.0-b2](https://github.com/ossrs/srs/releases/tag/v4.0-b2), v4.0-b2, 4.0 beta2, v4.0.215, 144278 lines. diff --git a/trunk/conf/docker.conf b/trunk/conf/docker.conf index dc7a2368b..f4ae9cd35 100644 --- a/trunk/conf/docker.conf +++ b/trunk/conf/docker.conf @@ -3,6 +3,8 @@ listen 1935; max_connections 1000; +# For docker, please use docker logs to manage the logs of SRS. +# See https://docs.docker.com/config/containers/logging/ srs_log_tank console; daemon off; http_api { diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index a2c9b6fc7..6b3acdb21 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -32,6 +32,10 @@ The changelog for SRS. ## SRS 4.0 Changelog +* v4.0, 2022-02-03, Merge [#2888](https://github.com/ossrs/srs/pull/2888): Fix bug when the value of http header is empty. (#2888). v4.0.237 +* v4.0, 2022-01-30, Refine docker console, preview by players at the same server. v4.0.236 +* v4.0, 2022-01-30, For docker, always use the console for logging. v4.0.235 +* v4.0, 2022-01-29, Merge [#2896](https://github.com/ossrs/srs/pull/2896): SRT: Reduce the SRT bug by limit the max times for retry. (#2896). v4.0.234 * v4.0, 2022-01-23, Merge [#2886](https://github.com/ossrs/srs/pull/2886): Fix bug when free addrinfo. (#2886). v4.0.233 * v4.0, 2022-01-22, Merge [#2887](https://github.com/ossrs/srs/pull/2887): Fix memory leak in SrsMetaCache. (#2887). v4.0.232 * v4.0, 2022-01-21, Support docker image for [lighthouse](https://hub.docker.com/r/ossrs/lighthouse). v4.0.231 diff --git a/trunk/research/console/js/srs.console.js b/trunk/research/console/js/srs.console.js index 95c3a5d11..e463ea827 100644 --- a/trunk/research/console/js/srs.console.js +++ b/trunk/research/console/js/srs.console.js @@ -570,7 +570,7 @@ scApp.filter('sc_filter_style_error', function(){ scApp.filter('sc_filter_preview_url', ['$sc_server', function($sc_server){ return function(v){ - var page = $sc_server.schema + "://ossrs.net/players/srs_player.html"; + var page = $sc_server.schema + `://${$sc_server.host}:${$sc_server.http}/players/srs_player.html`; var http = $sc_server.http[$sc_server.http.length - 1]; var query = "vhost=" + v.owner.name + "&app=" + v.app + "&stream=" + v.name + ".flv"; query += "&server=" + $sc_server.host +"&port=" + http + "&autostart=true&schema=" + $sc_server.schema; @@ -685,6 +685,10 @@ scApp.provider("$sc_server", [function(){ } else { self.port = $location.port(); } + + if ($location.search().http) { + self.http = [$location.search().http]; + } } }; return self; diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index bbcd085a1..559634406 100644 --- a/trunk/src/core/srs_core_version4.hpp +++ b/trunk/src/core/srs_core_version4.hpp @@ -9,6 +9,6 @@ #define VERSION_MAJOR 4 #define VERSION_MINOR 0 -#define VERSION_REVISION 233 +#define VERSION_REVISION 237 #endif diff --git a/trunk/src/srt/srt_conn.cpp b/trunk/src/srt/srt_conn.cpp index e085ea396..52c126751 100644 --- a/trunk/src/srt/srt_conn.cpp +++ b/trunk/src/srt/srt_conn.cpp @@ -122,7 +122,8 @@ bool get_streamid_info(const std::string& streamid, int& mode, std::string& url_ } srt_conn::srt_conn(SRTSOCKET conn_fd, const std::string& streamid):_conn_fd(conn_fd), - _streamid(streamid) { + _streamid(streamid), + write_fail_cnt_(0) { get_streamid_info(streamid, _mode, _url_subpath); _update_timestamp = now_ms(); @@ -195,7 +196,13 @@ int srt_conn::write(unsigned char* data, int len) { ret = srt_send(_conn_fd, (char*)data, len); if (ret <= 0) { srt_log_error("srt write error:%d, socket fd:%d", ret, _conn_fd); + write_fail_cnt_++; return ret; } + write_fail_cnt_ = 0; return ret; } + +int srt_conn::get_write_fail_count() { + return write_fail_cnt_; +} \ No newline at end of file diff --git a/trunk/src/srt/srt_conn.hpp b/trunk/src/srt/srt_conn.hpp index 1f6e44e21..5c632f7ef 100644 --- a/trunk/src/srt/srt_conn.hpp +++ b/trunk/src/srt/srt_conn.hpp @@ -44,6 +44,7 @@ public: void update_timestamp(long long now_ts); long long get_last_ts(); + int get_write_fail_count(); private: SRTSOCKET _conn_fd; @@ -52,6 +53,7 @@ private: std::string _vhost; int _mode; long long _update_timestamp; + int write_fail_cnt_; }; typedef std::shared_ptr SRT_CONN_PTR; diff --git a/trunk/src/srt/srt_handle.cpp b/trunk/src/srt/srt_handle.cpp index 4be705bf1..8c394653a 100644 --- a/trunk/src/srt/srt_handle.cpp +++ b/trunk/src/srt/srt_handle.cpp @@ -26,6 +26,7 @@ static long long MONITOR_TIMEOUT = 5000; const unsigned int DEF_DATA_SIZE = 188*7; const long long CHECK_ALIVE_INTERVAL = 5*1000; const long long CHECK_ALIVE_TIMEOUT = 5*1000; +static const int SRT_WRTIE_FAIL_MAX = 10; long long srt_now_ms = 0; @@ -215,6 +216,7 @@ void srt_handle::handle_push_data(SRT_SOCKSTATUS status, const std::string& subp srt_log_info("receive data size(%d) from pusher(%d) to pullers, count:%d", ret, conn_fd, streamid_iter->second.size()); + std::vector remove_vec; for (auto puller_iter = streamid_iter->second.begin(); puller_iter != streamid_iter->second.end(); puller_iter++) { @@ -227,6 +229,17 @@ void srt_handle::handle_push_data(SRT_SOCKSTATUS status, const std::string& subp srt_log_info("send data size(%d) to puller fd:%d", write_ret, puller_iter->first); if (write_ret > 0) { puller_iter->second->update_timestamp(srt_now_ms); + } else { + if (player_conn->get_write_fail_count() > SRT_WRTIE_FAIL_MAX) { + remove_vec.push_back(puller_iter->first); + } + } + } + + for (auto item : remove_vec) { + streamid_iter->second.erase(item); + if (streamid_iter->second.empty()) { + _streamid_map.erase(streamid_iter); } }