From 71dda68f62bbceda96079a742ff1eef6f2266024 Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 12 May 2021 21:17:57 +0800 Subject: [PATCH] Fix #2311, Copy the request for stat client. 3.0.162 --- README.md | 2 ++ trunk/src/app/srs_app_http_stream.cpp | 1 + trunk/src/app/srs_app_statistic.cpp | 6 +++++- trunk/src/core/srs_core_version3.hpp | 2 +- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index acea7810a..a1d6e812d 100755 --- a/README.md +++ b/README.md @@ -140,6 +140,7 @@ Other important wiki: ## 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. @@ -1718,6 +1719,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 #yyyyyyyyyyyyy]: https://github.com/ossrs/srs/issues/yyyyyyyyyyyyy [exo #828]: https://github.com/google/ExoPlayer/pull/828 diff --git a/trunk/src/app/srs_app_http_stream.cpp b/trunk/src/app/srs_app_http_stream.cpp index d28335b5c..9523010b0 100755 --- a/trunk/src/app/srs_app_http_stream.cpp +++ b/trunk/src/app/srs_app_http_stream.cpp @@ -938,6 +938,7 @@ 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); diff --git a/trunk/src/app/srs_app_statistic.cpp b/trunk/src/app/srs_app_statistic.cpp index e0f870a55..22c4f39f6 100644 --- a/trunk/src/app/srs_app_statistic.cpp +++ b/trunk/src/app/srs_app_statistic.cpp @@ -425,10 +425,14 @@ srs_error_t SrsStatistic::on_client(std::string id, SrsRequest* req, SrsConnecti // 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 0b1b470b1..9b683c37b 100644 --- a/trunk/src/core/srs_core_version3.hpp +++ b/trunk/src/core/srs_core_version3.hpp @@ -24,6 +24,6 @@ #ifndef SRS_CORE_VERSION3_HPP #define SRS_CORE_VERSION3_HPP -#define SRS_VERSION3_REVISION 161 +#define SRS_VERSION3_REVISION 162 #endif