#4768 Fixed race condition on active client proxy switch

This commit is contained in:
Jerry (Xinyu Hou) 2016-07-08 02:19:57 -07:00
parent 1a76acd446
commit 30fa5223bc
1 changed files with 12 additions and 9 deletions

View File

@ -496,6 +496,18 @@ Server::switchScreen(BaseClientProxy* dst,
} }
} }
// if already sending clipboard, we need to interupt it, otherwise
// clipboard data could be corrupted on the other side
// interrupt before switch active, as send clipboard uses active
// client proxy, which would cause race condition
if (m_sendClipboardThread != NULL) {
StreamChunker::setClipboardInterrupt(true);
m_sendClipboardThread->wait();
delete m_sendClipboardThread;
m_sendClipboardThread = NULL;
StreamChunker::setClipboardInterrupt(false);
}
// cut over // cut over
m_active = dst; m_active = dst;
@ -506,15 +518,6 @@ Server::switchScreen(BaseClientProxy* dst,
m_active->enter(x, y, m_seqNum, m_active->enter(x, y, m_seqNum,
m_primaryClient->getToggleMask(), m_primaryClient->getToggleMask(),
forScreensaver); forScreensaver);
// if already sending clipboard, we need to interupt it, otherwise
// clipboard data could be corrupted on the other side
if (m_sendClipboardThread != NULL) {
StreamChunker::setClipboardInterrupt(true);
m_sendClipboardThread->wait();
delete m_sendClipboardThread;
m_sendClipboardThread = NULL;
StreamChunker::setClipboardInterrupt(false);
}
// send the clipboard data to new active screen // send the clipboard data to new active screen
m_sendClipboardThread = new Thread( m_sendClipboardThread = new Thread(