From 6b7fc6fdb57d9386f754fb17cbcc46499d2aaa86 Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 23 Jan 2022 08:12:19 +0800 Subject: [PATCH 1/2] Squash: Fix bugs for 4.0 --- .github/workflows/release.yml | 14 ++++++++++++++ trunk/doc/CHANGELOG.md | 4 +++- trunk/src/app/srs_app_source.cpp | 2 ++ trunk/src/core/srs_core_version4.hpp | 2 +- trunk/src/kernel/srs_kernel_utility.cpp | 2 +- trunk/src/protocol/srs_service_st.cpp | 6 +++--- 6 files changed, 24 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 75b88d5af..2b5d85364 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -54,11 +54,14 @@ jobs: env: PACKAGER: ${{ secrets.SRS_PACKAGER_DOCKER }} PACKAGER_DROPLET: ${{ secrets.SRS_PACKAGER_DROPLET }} + PACKAGER_LIGHTHOUSE: ${{ secrets.SRS_PACKAGER_LIGHTHOUSE }} run: | echo "Release ossrs/srs:$SRS_TAG" docker build --tag ossrs/srs:$SRS_TAG --build-arg SRS_AUTO_PACKAGER=$PACKAGER -f trunk/Dockerfile . echo "Release ossrs/droplet:$SRS_TAG" docker build --tag ossrs/droplet:$SRS_TAG --build-arg SRS_AUTO_PACKAGER=$PACKAGER_DROPLET -f trunk/Dockerfile . + echo "Release ossrs/lighthouse:$SRS_TAG" + docker build --tag ossrs/lighthouse:$SRS_TAG --build-arg SRS_AUTO_PACKAGER=$PACKAGER_LIGHTHOUSE -f trunk/Dockerfile . # Docker hub # TODO: FIXME: If stable, please set the latest from 4.0 to 5.0 @@ -76,6 +79,10 @@ jobs: docker tag ossrs/droplet:$SRS_TAG ossrs/droplet:$SRS_MAJOR #docker tag ossrs/droplet:$SRS_TAG ossrs/droplet:latest docker push --all-tags ossrs/droplet + # + docker tag ossrs/lighthouse:$SRS_TAG ossrs/lighthouse:$SRS_MAJOR + docker tag ossrs/lighthouse:$SRS_TAG ossrs/lighthouse:latest + docker push --all-tags ossrs/lighthouse # Aliyun ACR hub # TODO: FIXME: If stable, please set the latest from 4.0 to 5.0 @@ -100,6 +107,13 @@ jobs: docker tag ossrs/droplet:$SRS_TAG registry.cn-hangzhou.aliyuncs.com/ossrs/droplet:$SRS_MAJOR #docker tag ossrs/droplet:$SRS_TAG registry.cn-hangzhou.aliyuncs.com/ossrs/droplet:latest docker push --all-tags registry.cn-hangzhou.aliyuncs.com/ossrs/droplet + # + docker tag ossrs/lighthouse:$SRS_TAG registry.cn-hangzhou.aliyuncs.com/ossrs/lighthouse:$SRS_TAG + docker tag ossrs/lighthouse:$SRS_TAG registry.cn-hangzhou.aliyuncs.com/ossrs/lighthouse:$SRS_VERSION + docker tag ossrs/lighthouse:$SRS_TAG registry.cn-hangzhou.aliyuncs.com/ossrs/lighthouse:v$SRS_MAJOR + docker tag ossrs/lighthouse:$SRS_TAG registry.cn-hangzhou.aliyuncs.com/ossrs/lighthouse:$SRS_MAJOR + docker tag ossrs/lighthouse:$SRS_TAG registry.cn-hangzhou.aliyuncs.com/ossrs/lighthouse:latest + docker push --all-tags registry.cn-hangzhou.aliyuncs.com/ossrs/lighthouse ################################################################################################################## ################################################################################################################## diff --git a/trunk/doc/CHANGELOG.md b/trunk/doc/CHANGELOG.md index 2b73287c5..a2c9b6fc7 100644 --- a/trunk/doc/CHANGELOG.md +++ b/trunk/doc/CHANGELOG.md @@ -32,7 +32,9 @@ The changelog for SRS. ## SRS 4.0 Changelog -* v4.0, 2022-01-17, Release v4.0-b4, 4.0 beta4, v4.0.230, 144393 lines. +* 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 * v4.0, 2022-01-17, Enable rtmp2rtc and rtc2rtmp for docker.conf * v4.0, 2022-01-17, Support docker image for [droplet](https://hub.docker.com/r/ossrs/droplet). v4.0.230 * v4.0, 2022-01-16, Update README for **Cloud Virtual Machine([CN](https://github.com/ossrs/srs/wiki/v4_CN_Home#cloud-virtual-machine) / [EN](https://github.com/ossrs/srs/wiki/v4_EN_Home#cloud-virtual-machine))** diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index a16d19015..40d208316 100755 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -1519,6 +1519,8 @@ SrsMetaCache::SrsMetaCache() SrsMetaCache::~SrsMetaCache() { dispose(); + srs_freep(vformat); + srs_freep(aformat); } void SrsMetaCache::dispose() diff --git a/trunk/src/core/srs_core_version4.hpp b/trunk/src/core/srs_core_version4.hpp index 4274d9601..bbcd085a1 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 230 +#define VERSION_REVISION 233 #endif diff --git a/trunk/src/kernel/srs_kernel_utility.cpp b/trunk/src/kernel/srs_kernel_utility.cpp index af1d3f384..896c0fb63 100644 --- a/trunk/src/kernel/srs_kernel_utility.cpp +++ b/trunk/src/kernel/srs_kernel_utility.cpp @@ -155,7 +155,7 @@ string srs_dns_resolve(string host, int& family) hints.ai_family = family; addrinfo* r = NULL; - SrsAutoFree(addrinfo, r); + SrsAutoFreeH(addrinfo, r, freeaddrinfo); if(getaddrinfo(host.c_str(), NULL, &hints, &r)) { return ""; } diff --git a/trunk/src/protocol/srs_service_st.cpp b/trunk/src/protocol/srs_service_st.cpp index a8568332f..a3510662f 100644 --- a/trunk/src/protocol/srs_service_st.cpp +++ b/trunk/src/protocol/srs_service_st.cpp @@ -171,7 +171,7 @@ srs_error_t srs_tcp_connect(string server, int port, srs_utime_t tm, srs_netfd_t hints.ai_socktype = SOCK_STREAM; addrinfo* r = NULL; - SrsAutoFree(addrinfo, r); + SrsAutoFreeH(addrinfo, r, freeaddrinfo); if(getaddrinfo(server.c_str(), sport, (const addrinfo*)&hints, &r)) { return srs_error_new(ERROR_SYSTEM_IP_INVALID, "get address info"); } @@ -248,7 +248,7 @@ srs_error_t srs_tcp_listen(std::string ip, int port, srs_netfd_t* pfd) hints.ai_flags = AI_NUMERICHOST; addrinfo* r = NULL; - SrsAutoFreeF(addrinfo, r); + SrsAutoFreeH(addrinfo, r, freeaddrinfo); if(getaddrinfo(ip.c_str(), sport, (const addrinfo*)&hints, &r)) { return srs_error_new(ERROR_SYSTEM_IP_INVALID, "getaddrinfo hints=(%d,%d,%d)", hints.ai_family, hints.ai_socktype, hints.ai_flags); @@ -309,7 +309,7 @@ srs_error_t srs_udp_listen(std::string ip, int port, srs_netfd_t* pfd) hints.ai_flags = AI_NUMERICHOST; addrinfo* r = NULL; - SrsAutoFree(addrinfo, r); + SrsAutoFreeH(addrinfo, r, freeaddrinfo); if(getaddrinfo(ip.c_str(), sport, (const addrinfo*)&hints, &r)) { return srs_error_new(ERROR_SYSTEM_IP_INVALID, "getaddrinfo hints=(%d,%d,%d)", hints.ai_family, hints.ai_socktype, hints.ai_flags); From b94ce1485ab36a86b9acf9c8968a402e1bb8b13b Mon Sep 17 00:00:00 2001 From: Haibo Chen Date: Thu, 3 Feb 2022 15:05:09 +0800 Subject: [PATCH 2/2] Fix bug when the value of http header is empty (#2888) * Fix bug when the value of http header is empty * add utest --- trunk/src/protocol/srs_service_http_conn.cpp | 10 +++++----- trunk/src/utest/srs_utest_http.cpp | 21 ++++++++++++++++++++ 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/trunk/src/protocol/srs_service_http_conn.cpp b/trunk/src/protocol/srs_service_http_conn.cpp index b1365c13a..f5fd10fd7 100644 --- a/trunk/src/protocol/srs_service_http_conn.cpp +++ b/trunk/src/protocol/srs_service_http_conn.cpp @@ -263,12 +263,12 @@ int SrsHttpParser::on_header_value(http_parser* parser, const char* at, size_t l if (length > 0) { obj->field_value.append(at, (int)length); - } - // When header parsed, we must save the position of start for body, - // because we have to consume the header in buffer. - // @see https://github.com/ossrs/srs/issues/1508 - obj->p_header_tail = at; + // When header parsed, we must save the position of start for body, + // because we have to consume the header in buffer. + // @see https://github.com/ossrs/srs/issues/1508 + obj->p_header_tail = at; + } srs_info("Header value(%d bytes): %.*s", (int)length, (int)length, at); return 0; diff --git a/trunk/src/utest/srs_utest_http.cpp b/trunk/src/utest/srs_utest_http.cpp index e5de7dd0d..c32fa77ac 100644 --- a/trunk/src/utest/srs_utest_http.cpp +++ b/trunk/src/utest/srs_utest_http.cpp @@ -143,6 +143,16 @@ string mock_http_response2(int status, string content) return ss.str(); } +string mock_http_response3(int status, string content) +{ + stringstream ss; + ss << "HTTP/1.1 " << status << " " << srs_generate_http_status_text(status) << "\r\n" + << "Server:" << "\r\n" + << "\r\n" + << content; + return ss.str(); +} + bool is_string_contain(string substr, string str) { return (string::npos != str.find(substr)); @@ -528,6 +538,17 @@ VOID TEST(ProtocolHTTPTest, ClientRequest) EXPECT_STREQ("Hello, world!", res.c_str()); srs_freep(msg); } + + // Normal case, with empty server. + if(true) { + MockBufferIO io; io.append(mock_http_response3(200, "Hello, world!")); + SrsHttpParser hp; HELPER_ASSERT_SUCCESS(hp.initialize(HTTP_RESPONSE)); + ISrsHttpMessage* msg = NULL; HELPER_ASSERT_SUCCESS(hp.parse_message(&io, &msg)); + string res; HELPER_ASSERT_SUCCESS(msg->body_read_all(res)); + EXPECT_EQ(200, msg->status_code()); + EXPECT_STREQ("Hello, world!", res.c_str()); + srs_freep(msg); + } } VOID TEST(ProtocolHTTPTest, ResponseHTTPError)