MXS-2217: Pick DCB owner before adding to epoll

There is a race condition between the addition of the DCB into epoll and
the execution of the event that initiates the protocol pointer for the DCB
and sends the handshake to the client. If a hangup event would occur
before the handshake would be sent, it would be possible that the DCB
would get freed before the code that sends the handshake is executed.

By picking the worker who owns the DCB before the DCB is placed into the
owner's epoll instance, we make sure no events arrive on the DCB while the
control is transferred from the accepting worker to the owning
worker.
This commit is contained in:
Markus Mäkelä
2019-01-16 21:03:19 +02:00
parent 519cd7d889
commit a469ef83b6
2 changed files with 31 additions and 35 deletions

View File

@ -3612,8 +3612,8 @@ int poll_add_dcb(DCB* dcb)
}
else
{
// Round-robin the client connection worker assignment
owner = RoutingWorker::pick_worker();
// Assign to current worker
owner = RoutingWorker::get_current();
}
new_state = DCB_STATE_POLLING;