Skip to content

stop() on a listen event does not stop accepting #305

Closed

Description

@EdmondDantes

libuv_listen_stop (libuv_reactor.c) only zeroes loop_ref_count and decrements the event count: libuv has no call that undoes uv_listen (checked in libuv v1.52.1: uv__tcp_listen starts the POLLIN watcher, and uv_read_stop is a no-op on a listening handle because UV_HANDLE_READING is never set). A stopped listen event therefore keeps accepting, and every connection reaches its callbacks.

Consumer impact: true-async-server pauses its listeners at its connection cap so that new connections wait in the kernel backlog; instead each one is accepted and answered 503 by the server's safety net. Reproduced 5 of 5 by the server's tests/phpt/server/h1/062-h1-paused-listener-leaves-the-backlog.phpt.

Fix (reviewed by a Critic and a Sage before code): pause by leaving the connection unaccepted. On Unix libuv then stops watching the socket itself (unix/stream.c:528-531) and restarts on the next successful uv_accept; on Windows a completed AcceptEx stays pending and is not re-posted. The first start() runs uv_listen; a later one unpauses and delivers the held connection on the next loop tick. A uv_poll accept loop was rejected: several polls on one socket busy-loop on Windows, EMFILE would spin, and named pipes cannot be polled.

Activity

  1. added 2 commits that reference this issue on Sep 30, 2026
  2. EdmondDantes commented on Sep 30, 2026

    @EdmondDantes
    ContributorAuthor

    Fixed by #306.

  3. added a commit that references this issue on Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions