8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 21:23:04 +01:00

Fixed bug #7661 : FB3 CS rejects new connections

This commit is contained in:
Vlad Khorsun 2023-07-29 13:22:41 +03:00
parent ede803a9cd
commit dd1942d8a5

View File

@ -676,18 +676,14 @@ public:
sharedMemory->eventFini(&sMem->process[process].notifyEvent);
sharedMemory->eventFini(&sMem->process[process].callbackEvent);
bool found = false;
for (unsigned n = 0; n < sMem->processes; ++n)
while (sMem->processes)
{
if (sMem->process[n].flags & MappingHeader::FLAG_ACTIVE)
{
found = true;
if (sMem->process[sMem->processes - 1].flags & MappingHeader::FLAG_ACTIVE)
break;
}
sMem->processes--;
}
if (!found)
if (!sMem->processes)
sharedMemory->removeMapFile();
}
@ -753,15 +749,21 @@ public:
(Arg::Gds(isc_map_event) << "POST").raise();
}
int tout = 0;
while (sharedMemory->eventWait(&current->callbackEvent, value, 10000) != FB_SUCCESS)
{
if (!ISC_check_process_existence(p->id))
{
MAP_DEBUG(fprintf(stderr, "clearMapping: dead process found %d", p->id));
p->flags &= ~MappingHeader::FLAG_ACTIVE;
sharedMemory->eventFini(&p->notifyEvent);
sharedMemory->eventFini(&p->callbackEvent);
break;
}
if (++tout >= 1000) // 10 sec
(Arg::Gds(isc_random) << "Timeout when waiting callback from other process.").raise();
}
MAP_DEBUG(fprintf(stderr, "Notified pid %d about reset map %s\n", p->id, sMem->databaseForReset));
@ -806,17 +808,34 @@ public:
Guard gShared(tempSharedMemory);
for (process = 0; process < sMem->processes; ++process)
process = sMem->processes;
for (unsigned idx = 0; idx < sMem->processes; ++idx)
{
if (!(sMem->process[process].flags & MappingHeader::FLAG_ACTIVE))
break;
MappingHeader::Process& p = sMem->process[idx];
if (!ISC_check_process_existence(sMem->process[process].id))
if (p.id == processId)
{
tempSharedMemory->eventFini(&sMem->process[process].notifyEvent);
tempSharedMemory->eventFini(&sMem->process[process].callbackEvent);
if (p.flags & MappingHeader::FLAG_ACTIVE) {
MAP_DEBUG(fprintf(stderr, "MappingIpc::setup: found existing entry for pid %d", processId));
}
break;
process = idx;
continue;
}
if ((p.flags & MappingHeader::FLAG_ACTIVE) && !ISC_check_process_existence(p.id))
{
MAP_DEBUG(fprintf(stderr, "MappingIpc::setup: dead process found %d", p.id));
p.flags = 0;
tempSharedMemory->eventFini(&p.notifyEvent);
tempSharedMemory->eventFini(&p.callbackEvent);
}
if (!(p.flags & MappingHeader::FLAG_ACTIVE))
{
if (process == sMem->processes)
process = idx;
}
}