MCPcopy Create free account
hub / github.com/MusicPlayerDaemon/MPD / OpenUringInputStream

Function OpenUringInputStream

src/input/plugins/UringInputPlugin.cxx:164–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

162}
163
164InputStreamPtr
165OpenUringInputStream(const char *path, Mutex &mutex)
166{
167 if (!uring_input_initialized) {
168 BlockingCall(*uring_input_event_loop, [](){
169 if (uring_input_initialized)
170 return;
171
172 uring_input_queue = uring_input_event_loop->GetUring();
173 uring_input_initialized = true;
174 });
175 }
176
177 if (uring_input_queue == nullptr)
178 return nullptr;
179
180 // TODO: use IORING_OP_OPENAT
181 auto fd = OpenReadOnly(path);
182
183 // TODO: use IORING_OP_STATX
184 struct stat st;
185 if (fstat(fd.Get(), &st) < 0)
186 throw FmtErrno("Failed to access {}", path);
187
188 if (!S_ISREG(st.st_mode))
189 throw FmtRuntimeError("Not a regular file: {}", path);
190
191 return std::make_unique<UringInputStream>(*uring_input_event_loop,
192 *uring_input_queue,
193 path, std::move(fd),
194 st.st_size, mutex);
195}
196
197void
198InitUringInputPlugin(EventLoop &event_loop) noexcept

Callers 1

OpenLocalInputStreamFunction · 0.85

Calls 4

BlockingCallFunction · 0.85
OpenReadOnlyFunction · 0.85
GetUringMethod · 0.80
GetMethod · 0.45

Tested by

no test coverage detected