Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: cosocket use mem pool #2036

Closed
wants to merge 6 commits into from

Conversation

xiaobiaozhao
Copy link
Contributor

I hereby granted the copyright of the changes in this pull request
to the authors of this lua-nginx-module project.

# Why do we need this PR?
When we use Cosocket in a long connection, the memory used to establish a new connection at the back end is not immediately freed, causing memory to continue to grow until the long connection is disconnected.
Fix this problem by using the pool of new links to free up memory when new links break

The demo will not leak memory

location = /{
                content_by_lua_block {
                for i = 0, 0xffffffff do
                    local sock = ngx.socket.tcp()
                    local ok, err = sock:connect("127.0.0.1", 12345)
                    if not ok then
                        ngx.log(ngx.INFO, "failed to connect to peer: ", err)
                    end
                    local ok = sock:receive("*l")
                    assert(ok == "OK")
                    sock:close()
                end
            }
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants