Skip to content

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

@bountyHntr

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions