diff --git a/AGENTS.md b/AGENTS.md index ea6b69e35..56af0b49e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -3,29 +3,38 @@ This is the guide for the OpenAI Codex agent. ## General repository layout -- Source code: trunk/src/ contains the C++ code for the SRS server. - - trunk/src/core and trunk/src/kernel contain the common definitions. - - trunk/src/protocol contains the media streaming protocol implementations. - - trunk/src/app contains the application-level implementations. - - trunk/src/main contains the main entry points for the programs. -- Source code: proxy/ contains the proxy server in Go for RTMP/SRT/WebRTC proxying. +- Source code: + - `trunk/src/` contains the major C++ code for the SRS server. + - `trunk/src/core` and trunk/src/kernel contain the common definitions. + - `trunk/src/protocol` contains the media streaming protocol implementations. + - `trunk/src/app` contains the application-level implementations. + - `trunk/src/main` contains the main entry points for the programs. + - `proxy/` contains the proxy server in Go for RTMP/SRT/WebRTC proxying. + - `trunk/src/core/srs_core_autofree.hpp` defines the smart pointer; you should review it before fixing memory issues. - Configuration: - - trunk/conf/full.conf contains all supported configurations. - - trunk/src/app/srs_app_config.cpp parses and checks the configuration file. - - trunk/conf/*.conf contains other example configuration files. -- UTests: trunk/src/utest contains the unit tests using gtest. -- Third-party dependencies: trunk/3rdparty contains the dependency libraries. You may refer to these codes, but never attempt to change or update them. - - trunk/3rdparty/st-srs is the coroutine library (state-threads). - - trunk/3rdparty/srs-bench is the integration test tool for blackbox tests. - - trunk/3rdparty/gtest-fit is the gtest framework used for unit tests. - - trunk/3rdparty/ffmpeg-4-fit is the codec library for transcoding audio streams such as AAC with Opus. - - trunk/3rdparty/openssl-1.1-fit is used for RTMP handshake and WebRTC DTLS handshake. - - trunk/3rdparty/libsrtp-2-fit is used for SRTP in WebRTC. - - trunk/3rdparty/srt-1-fit is the SRT implementation. + - `trunk/conf/full.conf` contains all supported configurations. + - `trunk/src/app/srs_app_config.cpp` parses and checks the configuration file. + - `trunk/conf/*.conf` contains other example configuration files. +- Tests: + - `trunk/src/utest` contains the unit tests using gtest. + - `trunk/3rdparty/srs-bench` is the integration test tool for blackbox tests. +- Third-party dependencies: `trunk/3rdparty` contains the dependency libraries. You may refer to these codes, but never attempt to change or update. + - `trunk/3rdparty/st-srs` is the coroutine library (state-threads). + - `trunk/3rdparty/gtest-fit` is the gtest framework used for unit tests. + - `trunk/3rdparty/ffmpeg-4-fit` is the codec library for transcoding audio streams such as AAC with Opus. + - `trunk/3rdparty/openssl-1.1-fit` is used for RTMP handshake and WebRTC DTLS handshake. + - `trunk/3rdparty/libsrtp-2-fit` is used for SRTP in WebRTC. + - `trunk/3rdparty/srt-1-fit` is the SRT implementation. - Documentation: - - README.md is a brief introduction to this project. - - trunk/doc/CHANGELOG.md contains the changelog history. + - `README.md` is a brief introduction to this project. + - `trunk/doc/CHANGELOG.md` contains the changelog history. + - `trunk/doc/Dockers.md` is the guide for building Docker images. +- Build: + - `trunk/configure` is the script used to configure the project; after running it, you can use make to build. + - `Dockerfile` is the main Docker file for building the image. + - `trunk/Dockerfile.test` is used to build the image for testing. + - `trunk/Dockerfile.builds` is used to verify builds on different target platforms. ## Testing Instructions -- Run CI tests defined in .github/workflows/test.yml file. +- Run CI tests defined in `.github/workflows/test.yml` file. - Add or update tests for the code you change, even if nobody asked. diff --git a/trunk/src/app/srs_app_caster_flv.cpp b/trunk/src/app/srs_app_caster_flv.cpp index d26c3ebd3..64c934a94 100644 --- a/trunk/src/app/srs_app_caster_flv.cpp +++ b/trunk/src/app/srs_app_caster_flv.cpp @@ -95,6 +95,12 @@ SrsAppCasterFlv::~SrsAppCasterFlv() { srs_freep(http_mux); srs_freep(manager); + + std::vector::iterator it; + for (it = conns.begin(); it != conns.end(); ++it) { + ISrsConnection* conn = *it; + srs_freep(conn); + } } srs_error_t SrsAppCasterFlv::initialize(SrsConfDirective* c) diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp index 7932a9002..d1d5c7fbe 100644 --- a/trunk/src/app/srs_app_server.cpp +++ b/trunk/src/app/srs_app_server.cpp @@ -1275,6 +1275,7 @@ srs_error_t SrsServer::do_on_tcp_client(ISrsListener* listener, srs_netfd_t& stf conn_manager->add(resource); // If connection is a resource to start, start a coroutine to handle it. + // Note that conn is managed by conn_manager, so we don't need to free it. ISrsStartable* conn = dynamic_cast(resource); srs_assert(conn); if ((err = conn->start()) != srs_success) { diff --git a/trunk/src/app/srs_app_srt_server.cpp b/trunk/src/app/srs_app_srt_server.cpp index 68fab0a6e..a383c8e8e 100644 --- a/trunk/src/app/srs_app_srt_server.cpp +++ b/trunk/src/app/srs_app_srt_server.cpp @@ -236,6 +236,7 @@ srs_error_t SrsSrtServer::accept_srt_client(srs_srt_t srt_fd) // directly enqueue, the cycle thread will remove the client. conn_manager_->add(resource); + // Note that conn is managed by conn_manager, so we don't need to free it. ISrsStartable* conn = dynamic_cast(resource); if ((err = conn->start()) != srs_success) { return srs_error_wrap(err, "start srt conn coroutine");