Commit Graph
21 Commits
Author SHA1 Message Date
Ken Sanislo b3a2cccfed NetworkServer: per-client send thread for SignalUpdate notifications
RGBController_UpdateCallback sent the SignalUpdate packet synchronously
via SendRequest_RGBController_SignalUpdate, which runs inside
RGBController::SignalUpdate. A blocking send there (slow client) keeps
SignalCalls > 0, so WaitSignalCalls -- the callback drain that
Unregister/ClearCallbacks/Shutdown run while tearing callbacks down on a
rescan -- waits forever. That is the client/server rescan deadlock.

Each client now owns an outbound queue and a dedicated send thread. The
signal path builds the packet (brief AccessMutex, as before) and queues
it; the client's own thread does the blocking send. A slow client backs
up only its own queue and blocks only its own thread, so the signal path
and the callback drain are never blocked.

UPDATELEDS packets coalesce per controller (a newer frame replaces the
pending one), so a stalled client's queue stays bounded to one packet
per controller instead of growing without bound; non-coalescable events
fall back to a hard cap with drop-oldest. The client destructor stops
the thread with shutdown(SD_BOTH), which unblocks an in-flight send, so
the join at teardown cannot hang. A queue entry owns its packet header
and data buffer; the send thread frees the buffer after the send, so
there is no copy and the packet outlives the controller safely.

Follow-up: the send still takes the shared send_in_progress, so a slow
client can still stall sends to others; routing response sends through
the same per-client path would make that a per-client lock.

net_port: add SD_BOTH (SHUT_RDWR) for the POSIX socket shims.
2026-07-29 11:25:06 -05:00
Adam Honse d09c66900d Set TCP_QUICKACK on Linux to improve responsiveness when using client/service configuration 2026-01-06 00:23:52 -06:00
Egor Vorontsov 56b75aaffc Set SO_REUSEADDR on network sockets. 2025-12-16 06:24:30 +03:00
Adam Honse c71cc4f18a Change SPDX license identifier from GPL 2.0 only to GPL 2.0 or later, as the original LICENSE file includes an or later clause at the end so the file headers were incorrect 2025-09-28 00:47:08 -05:00
Adam Honse 95b029d49d Initial support for Govee devices 2025-05-16 01:02:44 -05:00
Adam Honse 8126fbc4a3 Fix warnings in net_port.cpp 2025-01-16 23:44:58 -06:00
Adam Honse a3066db16c Update even more file header comments to standardized new format 2024-05-03 11:52:02 -05:00
Adam Honse 87aadafa4d Add timeout to Philips Wiz packet receive so that it doesn't hang on rescan 2023-05-08 00:03:07 -05:00
B Horn 640eb7905c SDK Listening Options 2022-07-17 20:30:15 +00:00
Nikita Rushmanov aae734a361 Fix segfault when destructing udp_client 2022-04-05 10:26:00 -07:00
Kasper 6ea3cdb8b7 QMK Improvements - make LEDs per update configurable
* Fix Windows include error that breaks std::min/max if a Windows header is included (tracked down to
net_port.h)

Commit amended by Adam Honse <calcprogrammer1@gmail.com>
2021-06-25 23:02:38 -05:00
Térence Clastres 53379c5482 Fixes for memory issues detected by valgrind 2020-08-12 23:48:03 -05:00
Adam Honse e2c2b8c1df Client will now close listener thread when disconnected and attempt to reconnect. Initialization behavior (controller requests, client string update) are performed automatically upon reconnection 2020-05-10 01:19:38 -05:00
Adam Honse 1c59ef6b80 Fix build on Linux 2020-05-09 15:48:15 -05:00
Adam Honse 5b42b3d11d Use TCP_NODELAY on client socket 2020-05-09 15:48:14 -05:00
Adam Honse 25f7a87a79 Get network server working in Windows 2020-05-09 15:48:14 -05:00
Adam Honse dff667751b Start work on network client 2020-05-09 15:48:12 -05:00
Adam Honse 46339c5f86 More work on network support, need to implement spawning of one read thread for each client socket 2020-05-09 15:48:12 -05:00
Steven Franzen dbf796256b Fix most compiler warnings 2019-12-31 19:18:24 -06:00
Adam Honse b5f687c402 Get project building on Windows again 2019-09-02 17:48:34 -05:00
Adam Honse 802d444d9d Add net port files 2019-09-01 15:43:42 -05:00