Files
mpd/src/io/uring/Close.cxx
Max Kellermann 2e3a51a5da io/uring/Close: use IOSQE_CQE_SKIP_SUCCESS
We don't want to get any completion events for "close".  It's
fire-and-forget.
2025-01-29 18:09:29 +01:00

27 lines
622 B
C++

// SPDX-License-Identifier: BSD-2-Clause
// Copyright CM4all GmbH
// author: Max Kellermann <mk@cm4all.com>
#include "Close.hxx"
#include "Queue.hxx"
#include "io/FileDescriptor.hxx"
namespace Uring {
void
Close(Queue *queue, FileDescriptor fd) noexcept
{
if (auto *s = queue != nullptr ? queue->GetSubmitEntry() : nullptr) {
io_uring_prep_close(s, fd.Get());
io_uring_sqe_set_data(s, nullptr);
io_uring_sqe_set_flags(s, IOSQE_CQE_SKIP_SUCCESS);
queue->Submit();
} else {
/* io_uring not available or queue full: fall back to
the classic close() system call */
fd.Close();
}
}
} // namespace Uring