diff --git a/README.md b/README.md index 89777056c..cd836db78 100755 --- a/README.md +++ b/README.md @@ -276,6 +276,7 @@ The ports used by SRS: ## V3 changes +* v3.0, 2021-05-12, Fix [#2311][bug #2311], Copy the request for stat client. 3.0.162 * v3.0, 2021-04-28, [3.0 release5(3.0.161)][r3.0r5] released. 122750 lines. * v3.0, 2021-04-28, Upgrade players. 3.0.161 * v3.0, 2021-04-24, [3.0 release4(3.0.160)][r3.0r4] released. 122750 lines. @@ -1912,6 +1913,7 @@ Winlin [bug #1987]: https://github.com/ossrs/srs/issues/1987 [bug #1548]: https://github.com/ossrs/srs/issues/1548 [bug #1694]: https://github.com/ossrs/srs/issues/1694 +[bug #2311]: https://github.com/ossrs/srs/issues/2311 [bug #413]: https://github.com/ossrs/srs/issues/413 [bug #2091]: https://github.com/ossrs/srs/issues/2091 [bug #1342]: https://github.com/ossrs/srs/issues/1342 diff --git a/trunk/src/app/srs_app_http_stream.cpp b/trunk/src/app/srs_app_http_stream.cpp index 5b32215ec..04a3f7a5a 100755 --- a/trunk/src/app/srs_app_http_stream.cpp +++ b/trunk/src/app/srs_app_http_stream.cpp @@ -76,7 +76,7 @@ SrsBufferCache::~SrsBufferCache() srs_freep(req); } -srs_error_t SrsBufferCache::update(SrsSource* s, SrsRequest* r) +srs_error_t SrsBufferCache::update_auth(SrsSource* s, SrsRequest* r) { srs_freep(req); req = r->copy(); @@ -527,7 +527,7 @@ SrsLiveStream::~SrsLiveStream() srs_freep(req); } -srs_error_t SrsLiveStream::update(SrsSource* s, SrsRequest* r) +srs_error_t SrsLiveStream::update_auth(SrsSource* s, SrsRequest* r) { source = s; @@ -953,9 +953,10 @@ srs_error_t SrsHttpStreamServer::http_mount(SrsSource* s, SrsRequest* r) } srs_trace("http: mount flv stream for sid=%s, mount=%s", sid.c_str(), mount.c_str()); } else { + // The entry exists, we reuse it and update the request of stream and cache. entry = sflvs[sid]; - entry->stream->update(s, r); - entry->cache->update(s, r); + entry->stream->update_auth(s, r); + entry->cache->update_auth(s, r); } if (entry->stream) { diff --git a/trunk/src/app/srs_app_http_stream.hpp b/trunk/src/app/srs_app_http_stream.hpp index 1ba6c1e5a..82d62db39 100755 --- a/trunk/src/app/srs_app_http_stream.hpp +++ b/trunk/src/app/srs_app_http_stream.hpp @@ -46,7 +46,7 @@ private: public: SrsBufferCache(SrsSource* s, SrsRequest* r); virtual ~SrsBufferCache(); - virtual srs_error_t update(SrsSource* s, SrsRequest* r); + virtual srs_error_t update_auth(SrsSource* s, SrsRequest* r); public: virtual srs_error_t start(); virtual srs_error_t dump_cache(SrsConsumer* consumer, SrsRtmpJitterAlgorithm jitter); @@ -189,7 +189,7 @@ private: public: SrsLiveStream(SrsSource* s, SrsRequest* r, SrsBufferCache* c); virtual ~SrsLiveStream(); - virtual srs_error_t update(SrsSource* s, SrsRequest* r); + virtual srs_error_t update_auth(SrsSource* s, SrsRequest* r); public: virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r); private: diff --git a/trunk/src/app/srs_app_statistic.cpp b/trunk/src/app/srs_app_statistic.cpp index e637e7199..4e58e9511 100644 --- a/trunk/src/app/srs_app_statistic.cpp +++ b/trunk/src/app/srs_app_statistic.cpp @@ -460,10 +460,14 @@ srs_error_t SrsStatistic::on_client(SrsContextId cid, SrsRequest* req, ISrsExpir // got client. client->conn = conn; - client->req = req; client->type = type; stream->nb_clients++; vhost->nb_clients++; + + // The req might be freed, in such as SrsLiveStream::update, so we must copy it. + // @see https://github.com/ossrs/srs/issues/2311 + srs_freep(client->req); + client->req = req->copy(); return err; } diff --git a/trunk/src/core/srs_core_version3.hpp b/trunk/src/core/srs_core_version3.hpp index dce1ed4d0..de1a7a578 100644 --- a/trunk/src/core/srs_core_version3.hpp +++ b/trunk/src/core/srs_core_version3.hpp @@ -26,6 +26,6 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 0 -#define SRS_VERSION3_REVISION 161 +#define SRS_VERSION3_REVISION 162 #endif