The calling thread is undefined when the PollQueue services events.
This implies that PollEvents need to handle the case where they are
processed from a different thread than the thread that created the
event. This changeset adds temporary event queue migrations to the VNC
server, the ethernet tap device, and the terminal to protect them from
inter-thread calls.
void
VncServer::accept()
{
+ // As a consequence of being called from the PollQueue, we might
+ // have been called from a different thread. Migrate to "our"
+ // thread.
+ EventQueue::ScopedMigration migrate(eventQueue());
+
if (!listener.islistening())
panic("%s: cannot accept a connection if not listening!", name());
void
TapListener::accept()
{
+ // As a consequence of being called from the PollQueue, we might
+ // have been called from a different thread. Migrate to "our"
+ // thread.
+ EventQueue::ScopedMigration migrate(tap->eventQueue());
+
if (!listener.islistening())
panic("TapListener(accept): cannot accept if we're not listening!");
void
Terminal::DataEvent::process(int revent)
{
+ // As a consequence of being called from the PollQueue, we might
+ // have been called from a different thread. Migrate to "our"
+ // thread.
+ EventQueue::ScopedMigration migrate(term->eventQueue());
+
if (revent & POLLIN)
term->data();
else if (revent & POLLNVAL)