RdpConnection: fix data race / crash on shutdown

Fix a data race / crash on session teardown: the peer transport was being closed from several threads at once.

freerdp_peer_close() ran from the destructor and close() on the main thread, and from video-encoding threads via the three VideoStream close(VideoInitFailed) calls — all while the run thread was concurrently reading the same transport in CheckFileDescriptor(). TSAN flags the run thread in peer_recv_fastpath_pdu racing the teardown path, and it crashes (SIGSEGV) inside FreeRDP on shutdown (TSAN trace in the discussion below).

This gives the run thread sole ownership of the peer: it waits on a manual-reset stopEvent alongside the transport handles, and every close path just signals it (request_stop + SetEvent) rather than touching the peer. The run thread closes the peer as it exits; the destructor closes it directly only when the thread was never started.

Originally this MR also touched the SIGTERM and session-list teardown paths, but master has since handled those independently (SIGINT/SIGTERM through the event loop; not destroying a session mid-list-mutation), so it is now reduced to the transport-ownership fix.

Edited by Wensheng Tang

Merge request reports

Loading