| 691 | } |
| 692 | |
| 693 | void clearCache(const char* dbName, USHORT index) |
| 694 | { |
| 695 | PathName target; |
| 696 | expandDatabaseName(dbName, target, nullptr); |
| 697 | |
| 698 | setup(); |
| 699 | |
| 700 | Guard gShared(this); |
| 701 | |
| 702 | MappingHeader* sMem = sharedMemory->getHeader(); |
| 703 | target.copyTo(sMem->databaseForReset, sizeof(sMem->databaseForReset)); |
| 704 | sMem->resetIndex = index; |
| 705 | |
| 706 | // Set currentProcess |
| 707 | sMem->currentProcess = -1; |
| 708 | for (unsigned n = 0; n < sMem->processes; ++n) |
| 709 | { |
| 710 | MappingHeader::Process* p = &sMem->process[n]; |
| 711 | if (!(p->flags & MappingHeader::FLAG_ACTIVE)) |
| 712 | continue; |
| 713 | |
| 714 | if (p->id == processId) |
| 715 | { |
| 716 | sMem->currentProcess = n; |
| 717 | break; |
| 718 | } |
| 719 | } |
| 720 | |
| 721 | if (sMem->currentProcess < 0) |
| 722 | { |
| 723 | // did not find current process |
| 724 | // better ignore delivery than fail in it |
| 725 | gds__log("MappingIpc::clearCache() failed to find current process %d in shared memory", processId); |
| 726 | return; |
| 727 | } |
| 728 | MappingHeader::Process* current = &sMem->process[sMem->currentProcess]; |
| 729 | |
| 730 | // Deliver |
| 731 | for (unsigned n = 0; n < sMem->processes; ++n) |
| 732 | { |
| 733 | MappingHeader::Process* p = &sMem->process[n]; |
| 734 | if (!(p->flags & MappingHeader::FLAG_ACTIVE)) |
| 735 | continue; |
| 736 | |
| 737 | if (p->id == processId) |
| 738 | { |
| 739 | MAP_DEBUG(fprintf(stderr, "Internal resetMap(%s, %d)\n", sMem->databaseForReset, sMem->resetIndex)); |
| 740 | resetMap(sMem->databaseForReset, sMem->resetIndex); |
| 741 | continue; |
| 742 | } |
| 743 | |
| 744 | SLONG value = sharedMemory->eventClear(¤t->callbackEvent); |
| 745 | p->flags |= MappingHeader::FLAG_DELIVER; |
| 746 | |
| 747 | if (sharedMemory->eventPost(&p->notifyEvent) != FB_SUCCESS) |
| 748 | { |
| 749 | (Arg::Gds(isc_map_event) << "POST").raise(); |
| 750 | } |
nothing calls this directly
no test coverage detected