| 762 | |
| 763 | |
| 764 | ProfilerIpc::ProfilerIpc(thread_db* tdbb, MemoryPool& pool, AttNumber aAttachmentId, bool server) |
| 765 | : attachmentId(aAttachmentId), |
| 766 | isServer(server) |
| 767 | { |
| 768 | const auto database = tdbb->getDatabase(); |
| 769 | |
| 770 | string fileName; |
| 771 | static_assert(std::is_same<decltype(attachmentId), FB_UINT64>::value); |
| 772 | fileName.printf(PROFILER_FILE, database->getUniqueFileId().c_str(), attachmentId); |
| 773 | |
| 774 | try |
| 775 | { |
| 776 | sharedMemory = FB_NEW_POOL(pool) SharedMemory<Header>(fileName.c_str(), sizeof(Header), this); |
| 777 | } |
| 778 | catch (const Exception& ex) |
| 779 | { |
| 780 | iscLogException("ProfilerManager: cannot initialize the shared memory region", ex); |
| 781 | throw; |
| 782 | } |
| 783 | |
| 784 | const auto header = sharedMemory->getHeader(); |
| 785 | checkHeader(header); |
| 786 | |
| 787 | if (isServer) |
| 788 | { |
| 789 | Guard guard(this); |
| 790 | |
| 791 | if (sharedMemory->eventInit(&header->serverEvent) != FB_SUCCESS) |
| 792 | (Arg::Gds(isc_random) << "ProfilerIpc eventInit(serverEvent) failed").raise(); |
| 793 | } |
| 794 | } |
| 795 | |
| 796 | ProfilerIpc::~ProfilerIpc() |
| 797 | { |
nothing calls this directly
no test coverage detected