gui: reduce stopWorker wait from 200ms to 10ms

The fid close should immediately unblock reads. Don't wait long.
This commit is contained in:
Levi Neely 2026-10-06 11:38:28 +02:00
parent 65014395b7
commit 79738a4a39
1 changed files with 5 additions and 10 deletions

View File

@ -144,16 +144,12 @@ void Lib9pStreamer::stopWorker()
if (!m_worker)
return;
m_worker->requestStop();
m_worker->requestStop(); // Also closes fid to unblock read
// The worker may be blocked in Read(). We can't interrupt it directly,
// but we can abandon it. The thread will exit when:
// - Data arrives (checks stopRequested, exits)
// - EOF (server closes connection)
// - Error (connection lost)
//
// Give it a short time to exit gracefully, then abandon.
if (m_workerThread->wait(200)) {
// Give a very short time for the thread to notice the close.
// If it doesn't exit quickly, abandon it (it will clean up when the
// read finally returns).
if (m_workerThread->wait(10)) {
// Thread exited cleanly
delete m_worker;
delete m_workerThread;
@ -164,7 +160,6 @@ void Lib9pStreamer::stopWorker()
// Let the thread run to completion on its own
connect(m_workerThread, &QThread::finished, m_worker, &QObject::deleteLater);
connect(m_workerThread, &QThread::finished, m_workerThread, &QObject::deleteLater);
// Note: thread will eventually exit when the read completes or errors
}
m_worker = nullptr;