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

Method PreadSafe

util/system/direct_io.cpp:149–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147}
148
149size_t TDirectIOBufferedFile::PreadSafe(void* buffer, size_t byteCount, ui64 offset) {
150 if (FlushedToDisk < offset + byteCount) {
151 File.FlushData();
152 FlushedToDisk = FlushedBytes;
153 }
154
155#ifdef _linux_
156 ssize_t bytesRead = 0;
157 do {
158 bytesRead = pread(File.GetHandle(), buffer, byteCount, offset);
159 } while (bytesRead == -1 && errno == EINTR);
160
161 if (bytesRead < 0) {
162 ythrow yexception() << "error while pread file: " << LastSystemError() << "(" << LastSystemErrorText() << ")";
163 }
164
165 return bytesRead;
166#else
167 return File.Pread(buffer, byteCount, offset);
168#endif
169}
170
171size_t TDirectIOBufferedFile::ReadFromFile(void* buffer, size_t byteCount, ui64 offset) {
172 SetDirectIO(true);

Callers

nothing calls this directly

Calls 5

LastSystemErrorFunction · 0.85
LastSystemErrorTextFunction · 0.70
FlushDataMethod · 0.45
GetHandleMethod · 0.45
PreadMethod · 0.45

Tested by

no test coverage detected