Codex: Fix potential issues with memory leak.

This commit is contained in:
winlin 2025-05-21 11:16:29 -04:00
parent 2b0de99b5e
commit 53a6af659f
4 changed files with 38 additions and 21 deletions

View File

@ -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.

View File

@ -95,6 +95,12 @@ SrsAppCasterFlv::~SrsAppCasterFlv()
{
srs_freep(http_mux);
srs_freep(manager);
std::vector<ISrsConnection*>::iterator it;
for (it = conns.begin(); it != conns.end(); ++it) {
ISrsConnection* conn = *it;
srs_freep(conn);
}
}
srs_error_t SrsAppCasterFlv::initialize(SrsConfDirective* c)

View File

@ -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<ISrsStartable*>(resource);
srs_assert(conn);
if ((err = conn->start()) != srs_success) {

View File

@ -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<ISrsStartable*>(resource);
if ((err = conn->start()) != srs_success) {
return srs_error_wrap(err, "start srt conn coroutine");