8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-24 05:23:03 +01:00

Backport fix for race condition when two different events could use same instance of unused Rvnt.

Details at fb-devel, thread "Concurrency bugs in posting events?" by Mark Rotteveel.
Thanks to Adriano for discovering issue.
This commit is contained in:
hvlad 2017-04-14 00:17:17 +03:00
parent 40a7c45b27
commit c2d3266fce

View File

@ -917,17 +917,8 @@ public:
if (!allowCancel)
return;
if (event->rvnt_iface)
if (!(port->port_flags & PORT_disconnect))
{
LocalStatus ls;
CheckStatusWrapper status_vector(&ls);
event->rvnt_iface->cancel(&status_vector);
event->rvnt_iface = NULL;
}
if (port->port_flags & PORT_disconnect)
return;
PACKET packet;
packet.p_operation = op_event;
P_EVENT* p_event = &packet.p_event;
@ -939,6 +930,15 @@ public:
port->send(&packet);
}
if (event->rvnt_iface)
{
LocalStatus ls;
CheckStatusWrapper status_vector(&ls);
event->rvnt_iface->cancel(&status_vector);
event->rvnt_iface = NULL;
}
}
int release()
{
if (--refCounter == 0)
@ -4746,7 +4746,7 @@ ISC_STATUS rem_port::que_events(P_EVENT * stuff, PACKET* sendL)
{
if (!event->rvnt_iface)
{
event->rvnt_destroyed = 0;
if (event->rvnt_destroyed.compareExchange(1, 0))
break;
}
}