after unlinking Open will return false, and Create may map new region with same name.
| 66 | |
| 67 | // after unlinking Open will return false, and Create may map new region with same name. |
| 68 | void Close(const EUnlinkPolicy up = UP_CREATOR_UNLINKS) // default argument for compatibility with TSharedMemory |
| 69 | { |
| 70 | Y_ASSERT((Ptr == nullptr) == (Size == 0)); |
| 71 | Y_ASSERT((Fd == INVALID_HANDLE_VALUE) == Guid.IsEmpty()); |
| 72 | |
| 73 | if (Ptr != INVALID_POINTER_VALUE) { |
| 74 | munmap(Ptr, Size); |
| 75 | } |
| 76 | Ptr = INVALID_POINTER_VALUE; |
| 77 | Size = 0; |
| 78 | |
| 79 | if (Fd != INVALID_HANDLE_VALUE) { |
| 80 | close(Fd); |
| 81 | Unlink(up); |
| 82 | } |
| 83 | Fd = INVALID_HANDLE_VALUE; |
| 84 | Guid = TGUID(); |
| 85 | |
| 86 | IsCreator = false; |
| 87 | } |
| 88 | |
| 89 | // Nobody can Open this shared memory again! |
| 90 | // But this shared memory will be removed only when all attached processes exit (or terminate). |