void get_shared() { AcquireSRWLockShared ( &_lock ) ; }
void RWLockWindows::read_lock() { AcquireSRWLockShared(&lock); }
void WINAPI SRWLockReadCallback() { AcquireSRWLockShared(&g_srwLock); gv_value = 0; ReleaseSRWLockShared(&g_srwLock); }
_PPLXIMP void reader_writer_lock_impl::lock_read() { AcquireSRWLockShared(reinterpret_cast<PSRWLOCK>(&_M_impl)); }
void TRI_ReadLockReadWriteLock(TRI_read_write_lock_t* lock) { AcquireSRWLockShared(&lock->_lock); }
static int winfs_getdents(struct file *f, void *dirent, size_t count, getdents_callback *fill_callback) { AcquireSRWLockShared(&f->rw_lock); NTSTATUS status; struct winfs_file *winfile = (struct winfs_file *) f; IO_STATUS_BLOCK status_block; #define BUFFER_SIZE 32768 char buffer[BUFFER_SIZE]; int size = 0; for (;;) { /* sizeof(FILE_ID_FULL_DIR_INFORMATION) is larger than both sizeof(struct dirent) and sizeof(struct dirent64) * So we don't need to worry about header size. * For the file name, in worst case, a UTF-16 character (2 bytes) requires 4 bytes to store */ int buffer_size = (count - size) / 2; if (buffer_size >= BUFFER_SIZE) buffer_size = BUFFER_SIZE; status = NtQueryDirectoryFile(winfile->handle, NULL, NULL, NULL, &status_block, buffer, buffer_size, FileIdFullDirectoryInformation, FALSE, NULL, winfile->restart_scan); winfile->restart_scan = 0; if (!NT_SUCCESS(status)) { if (status != STATUS_NO_MORE_FILES) log_error("NtQueryDirectoryFile() failed, status: %x", status); break; } if (status_block.Information == 0) break; int offset = 0; FILE_ID_FULL_DIR_INFORMATION *info; do { info = (FILE_ID_FULL_DIR_INFORMATION *) &buffer[offset]; offset += info->NextEntryOffset; void *p = (char *)dirent + size; //uint64_t inode = info->FileId.QuadPart; /* Hash 64 bit inode to 32 bit to fix legacy applications * We may later add an option for changing this behaviour */ uint64_t inode = info->FileId.HighPart ^ info->FileId.LowPart; char type = DT_REG; if (info->FileAttributes & FILE_ATTRIBUTE_DIRECTORY) type = DT_DIR; else if (info->FileAttributes & FILE_ATTRIBUTE_SYSTEM) { /* Test if it is a symlink */ UNICODE_STRING pathname; pathname.Length = info->FileNameLength; pathname.MaximumLength = info->FileNameLength; pathname.Buffer = info->FileName; NTSTATUS status; IO_STATUS_BLOCK status_block; OBJECT_ATTRIBUTES attr; attr.Length = sizeof(OBJECT_ATTRIBUTES); attr.RootDirectory = winfile->handle; attr.ObjectName = &pathname; attr.Attributes = 0; attr.SecurityDescriptor = NULL; attr.SecurityQualityOfService = NULL; HANDLE handle; status = NtCreateFile(&handle, SYNCHRONIZE | FILE_READ_DATA, &attr, &status_block, NULL, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, FILE_OPEN, FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0); if (NT_SUCCESS(status)) { if (winfs_is_symlink_unsafe(handle)) type = DT_LNK; NtClose(handle); } else log_warning("NtCreateFile() failed, status: %x", status); } intptr_t reclen = fill_callback(p, inode, info->FileName, info->FileNameLength / 2, type, count - size, GETDENTS_UTF16); if (reclen < 0) { size = reclen; goto out; } size += reclen; } while (info->NextEntryOffset); } out: ReleaseSRWLockShared(&f->rw_lock); return size; #undef BUFFER_SIZE }
void WinReadWriteLock::lockForRead() { AcquireSRWLockShared(&m_lock); }
void SimpleRWLock::lock_shared() { AcquireSRWLockShared(&_lock); }
void FuncSRWLockRead() { AcquireSRWLockShared(&g_SRWlock); auto iRead = g_num; ReleaseSRWLockShared(&g_SRWlock); }
void SlimReaderWriterLock::lock_shared() { AcquireSRWLockShared( &mSrwlock ); }
inline void ReadWriteLockRead(ReadWriteLock* self) { AcquireSRWLockShared(&self->m_Impl); }