Skip to content

select/poll with timeout does not block #25759

@stevenwdv

Description

@stevenwdv

I noticed a high CPU usage for the WASM port of our product and traced it to an infinite select() loop in boost::asio sockets, see socket_ops.ipp, because the syscall does not use the timeout. We're using the default emulated TCP over web sockets implementation. select() is called on a PThread.

I wonder: why is this? It seems that emscripten_proxy_sync should be able to block just fine on a worker PThread.

Are there any plans to support blocking? How would you guys recommend solving this? Is the only option to use the WebSockets API directly instead? Should Boost fix this for the Emscripten case (they have more Emscripten-specific code blocks)?

Related: #19447, but that's about full POSIX Sockets over a WebSocket proxy server.

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 4.0.19 (08e2de1031913e4ba7963b1c56f35f036a7d4d56)
clang version 22.0.0git (https:/github.com/llvm/llvm-project 12f392cff10fcc70b4ec4f01ab386922742e9136)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /home/swdv/emsdk/upstream/bin

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