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

Missed semaphore Base.release(sem) after failed accept #1143

Open
bountyHntr opened this issue Feb 9, 2024 · 0 comments
Open

Missed semaphore Base.release(sem) after failed accept #1143

bountyHntr opened this issue Feb 9, 2024 · 0 comments

Comments

@bountyHntr
Copy link

# Servers.jl
function listenloop(f, listener, conns, tcpisvalid,
                       max_connections, readtimeout, access_log, ready_to_accept, verbose)
        sem = Base.Semaphore(max_connections)
        ...
        while isopen(listener)
                try
                    Base.acquire(sem)
                    io = accept(listener)
                    if io === nothing
                        @warnv 1 "unable to accept new connection"
                        continue
                    elseif !tcpisvalid(io)
                        @warnv 1 "!tcpisvalid: $io"
                        close(io)
                        continue
                    end
                    conn = Connection(io)
        ...

There is no Base.release(sem) before continue in the case when something wrong happens when calling accept. As a result, after each continue, semaphore max value decreases.

@bountyHntr bountyHntr changed the title Missed semaphore release after failed accept Missed semaphore Base.release(sem) after failed accept Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant