| 80 | } |
| 81 | |
| 82 | bool FileLock::platformUnLock(bool unlockToSharedLock) { |
| 83 | /* quote from MSDN: |
| 84 | * If the same range is locked with an exclusive and a shared lock, |
| 85 | * two unlock operations are necessary to unlock the region; |
| 86 | * the first unlock operation unlocks the exclusive lock, |
| 87 | * the second unlock operation unlocks the shared lock. |
| 88 | */ |
| 89 | if (unlockToSharedLock) { |
| 90 | auto flag = LockType2Flag(SharedLockType); |
| 91 | if (!LockFileEx(m_fd, flag, 0, 1, 0, &m_overLapped)) { |
| 92 | MMKVError("fail to roll back to shared-lock, error:%d", GetLastError()); |
| 93 | } |
| 94 | } |
| 95 | auto ret = UnlockFileEx(m_fd, 0, 1, 0, &m_overLapped); |
| 96 | if (!ret) { |
| 97 | auto lastError = GetLastError(); |
| 98 | if (lastError != ERROR_NOT_LOCKED) { |
| 99 | MMKVError("fail to unlock fd=%p, error:%d", m_fd, lastError); |
| 100 | return false; |
| 101 | } |
| 102 | } |
| 103 | return true; |
| 104 | } |
| 105 | |
| 106 | } // namespace mmkv |
| 107 |
nothing calls this directly
no test coverage detected