MCPcopy Create free account
hub / github.com/catboost/catboost / Unlink

Method Unlink

library/cpp/netliba/v12/posix_shared_memory.h:93–107  ·  view source on GitHub ↗

Nobody can Open this shared memory again! But this shared memory will be removed only when all attached processes exit (or terminate). Careful! Calling this method simultaneously from multiple processes may lead to unlinking another's shared memory! Better use with UP_CREATOR_UNLINKS flag.

Source from the content-addressed store, hash-verified

91 // Careful! Calling this method simultaneously from multiple processes may lead to unlinking another's shared memory!
92 // Better use with UP_CREATOR_UNLINKS flag.
93 bool Unlink(const EUnlinkPolicy up) {
94 // This method is the only reason to switch from System V shared memory (shmget/shmat/shmdt) to POSIX shared memory:
95 // using System V shared memory after shmdt is unspecified behavior: smhdt decrements refcount and after its call
96 // shared memory may be removed (if refcount == 0 && somebody called shmctl(IPC_RMID)) without waiting process to exit!
97 // But without calling it right after attaching we may have "shared memory leak" after unexpected processes termination.
98 // In the opposite unlinking POSIX shared memory is like unlinking files - nobody can open it again, but processes
99 // which already opened it will see no difference.
100 if (up == UP_FORCE_UNLINK || (IsCreator && up == UP_CREATOR_UNLINKS)) {
101 Y_ASSERT(!Unlinked && !Guid.IsEmpty());
102 Y_ABORT_UNLESS(!Unlinked, "You tried to unlink shared memory twice! Fix your code");
103 Unlinked = shm_unlink(ConvertGuidToName(Guid).c_str());
104 return Unlinked;
105 }
106 return true;
107 }
108
109 const TGUID& GetId() {
110 return Guid;

Callers 8

EraseMethod · 0.45
PromoteMethod · 0.45
EraseMethod · 0.45
EraseFromActiveMethod · 0.45
RegisterMethod · 0.45
RemoveMethod · 0.45
EraseUnsafeMethod · 0.45

Calls 2

IsEmptyMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected