mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-09-03 11:15:20 +02:00
NewThreadExecutor::Run pushed a std::thread per connection and only ever joined them in the destructor, so a server leaked a joinable thread object for every connection it had ever served. Measured with 60 connect/disconnect cycles against the debugger: handle count +60 before, +1 after. Each worker now flags itself done as its last act, and Run() reaps the finished ones first. Only the accept thread calls Run(), so the flag is the only thing that needs to be atomic. Note this doesn't bound how many connections can be in flight at once - it just stops the finished ones from piling up. Separately, a received close code was echoed straight back. RFC 6455 7.4.1 reserves 1004, 1005, 1006 and 1015 for describing how a connection ended locally, so they must never go on the wire - echoing one back would be our protocol violation rather than the client's. Send PROTOCOL_ERROR when they give us something we can't repeat.