Commit Graph
38 Commits
Author SHA1 Message Date
andrey 22a09ddd1c fix(picloud-dispatcher): start read thread under the lock and drain rmrf_* in the destructor
newConnection pushed the client into clients while holding map_mutex
but started its read thread after releasing it; in that window the
client was a live member of clients with no read thread and could be
marked, closed and deleted by the drainer before start() ran. Start
the thread inside the locked section: the thread can only wait for
map_mutex after the function has released it, so this is not a
deadlock, and the 'everything in clients is started' invariant holds.

~DispatcherServer dropped clients/servers pending in rmrf_clients/
rmrf_servers without closing or deleting them (object leak of live
PIObjects). Collect them together with the main maps, then run the
same stop/close/delete sequence. The sets are disjoint with the main
maps by construction (items are removed from the main maps when
marked), so there are no duplicates.
2026-08-23 18:55:15 +03:00
andrey cc8e8644f1 fix(picloud-dispatcher): do not close/delete clients under map_mutex — deadlock
cleanClients() (timer thread) called close()/stopAndWait() and
disconnectClient() (read thread) did the same while holding
map_mutex, while client read threads wait for the same lock in
registerServer/registerClient/disconnectClient — a guaranteed
deadlock (the -w watchdog aborts exactly this). disconnectClient
could also wait for its own read thread (self-wait in
waitThreadedReadFinished) and the destructor never stopped the timer
or drained the clients, leaving dangling lambda captures of this.

Restructure around a single drainer (the timer thread):
- cleanClients: under map_mutex only mark (move rmrf_* out, mark
  ping-timeout/orphaned clients); after the unlock close
  (stopAndWait) and delete the connections, then delete the servers
- disconnectClient: only mark under the lock, then request a
  non-blocking stop() on the affected connections; the drainer waits
  and deletes (no self-wait, nothing blocks while holding the lock)
- newConnection: start the read thread after releasing the lock
- ~DispatcherServer: stop watchdog/timer first, then close and delete
  all clients before the servers (raw-pointer order) and eth

The watchdog is now a PIThread member so the destructor can stop it;
setMaxConnections takes map_mutex like its readers.
2026-08-23 17:18:03 +03:00
peri4 92a87a0c64 picloud add "-w" option for watchdog 2024-10-15 15:04:39 +03:00
peri4 16a818c95e picloud hang fix try :`-( 2024-09-06 08:05:26 +03:00
peri4 1c7fc39b6c version 4.0.0_alpha
in almost all methods removed timeouts in milliseconds, replaced to PISystemTime
PITimer rewrite, remove internal impl, now only thread implementation, API similar to PIThread
PITimer API no longer pass void*
PIPeer, PIConnection improved stability on reinit and exit
PISystemTime new methods
pisd now exit without hanging
2024-07-30 14:18:02 +03:00
peri4 d46b5e008a try to fix cloud again 2024-06-01 22:27:39 +03:00
peri4 fb68a9f9fe another segv on cloud 2024-03-31 20:31:35 +03:00
peri4 c7c3852747 cloud! finally fixed bug! 2024-03-25 22:40:29 +03:00
peri4 9c4fd41eef 3 2024-03-25 21:37:05 +03:00
peri4 2db9440a38 fix cloud ... :-/ 2024-03-25 21:24:29 +03:00
peri4 0d585cfebf cloud fix ... (( 2024-03-25 21:17:05 +03:00
peri4 02a9bfb76f another try fix 2024-03-22 22:29:14 +03:00
peri4 ad7385c21f more couts 2024-03-22 21:40:04 +03:00
peri4 dd6d91ac1d cloud fixes ... 2024-03-18 10:45:57 +03:00
peri4 3fa5d9d9df cloud inspecting ... 2024-03-15 19:49:37 +03:00
peri4 2b738f6f43 more safety cloud_dispatcher 2024-03-10 21:22:05 +03:00
peri4 50bff12364 map and cloud fix, add cloud debug 2024-02-22 17:10:38 +03:00
peri4 2ac215c19e separate PIEthernet::Address to PINetworkAddress, typedef PIEthernet::Address to PINetworkAddress and mark as deprecated
PIValueTree new attributes for File and Dir
2022-12-19 14:29:18 +03:00
peri4 c2b8a8d6da code format 2022-12-14 14:13:52 +03:00
Бычков Андрей cb59017ebb PICloud many important fixes 2022-11-11 16:18:05 +03:00
Бычков Андрей 8738043dce some PICloud and PIEthernet fixes 2022-11-09 17:04:13 +03:00
Бычков Андрей 897f03f3d0 some fixes for picloud, but still not working correctly 2022-11-08 14:43:52 +03:00
andrey f82b6c12ee cloud_dispatcher patch 2021-09-01 22:43:40 +03:00
andrey 35a3ce6402 picloudtcp.cpp revert some mutex 2021-09-01 10:56:11 +03:00
andrey 4c0530d89a picloud ping and fix big bugs 2021-08-19 18:13:05 +03:00
andrey ee131921a0 add PIByteArray operator <, fix picloud 2021-08-12 20:22:43 +03:00
andrey f8818c8537 picloud patch 2021-08-12 19:50:17 +03:00
andrey ca09b9d14b piclouddispatcher patch 2021-08-06 10:49:14 +03:00
peri4 d0db8012e6 PICloud small patches 2021-07-20 21:11:33 +03:00
andrey 856a9b80ea PIVector reshape and etc... 2021-07-16 14:11:55 +03:00
andrey dbd2267a8c PICloud change protocol > server_uuid 2021-04-12 11:35:34 +03:00
andrey f75ce1e8e0 PICloud Dispatcher screen mode 2021-04-09 16:44:05 +03:00
andrey bf63b0e9f3 PIClout data send and receive test 2021-04-07 18:03:28 +03:00
andrey be0db84147 PICloud connect/disconnect 2021-04-06 15:24:58 +03:00
andrey f0d4801d3c picloud next iteration 2021-04-05 17:42:02 +03:00
andrey 234d4e73be picloud 2020-08-27 19:40:11 +03:00
andrey cfebf8cf23 cloud test 2020-08-26 17:28:56 +03:00
andrey 3f7f67e198 picloud start develop 2020-06-15 11:09:34 +03:00