Commit Graph

529 Commits

Author SHA1 Message Date
Max Kellermann
838398103c Revert "event/Thread: start the thread in the constructor"
This reverts commit b49cfe96f4.  It was
a bad idea because it broke signal handlers.  I need to find a better
way to fix io_uring intialization.
2025-01-30 19:58:15 +01:00
Max Kellermann
b49cfe96f4 event/Thread: start the thread in the constructor
This is the proper fix for the e309941646 regression; see
commit abc8420697
2025-01-30 10:58:34 +01:00
Max Kellermann
e309941646 event/Loop: initialize io_uring with IORING_SETUP_SINGLE_ISSUER
This might give tiny kernel-side optimizations.
2025-01-29 20:29:42 +01:00
Max Kellermann
ea2ced6b9f event/UringManager: replace with new Uring::Manager class
From https://github.com/CM4all/libcommon - the new class is mostly
identical, and I want to maintain only one of them.
2025-01-29 20:27:13 +01:00
Max Kellermann
7adda0aa66 event/ServerSocket: move GetPeerCredentials() call to ClientListener::OnAccept() 2025-01-29 19:32:53 +01:00
Max Kellermann
a0825e6ce0 net/PeerCredentials: add getpeereid() support 2025-01-29 19:28:09 +01:00
Max Kellermann
c7621ec0e4 net/PeerCredentials: wrapper for struct ucred 2025-01-29 19:28:03 +01:00
Max Kellermann
e682940c54 event/PipeEvent: add GetScheduledFlags(), [GS]etReadyFlags() 2025-01-29 18:09:10 +01:00
Max Kellermann
fa375cbaeb event/uring/Manager: un-inline the ctor 2025-01-29 18:09:06 +01:00
Max Kellermann
0ba0c64093 event/uring/Manager: add flags parameter 2025-01-29 18:07:46 +01:00
Max Kellermann
5e107c33d9 event/DeferEvent: add ScheduleNext() 2025-01-29 18:05:50 +01:00
Max Kellermann
4bb379a218 event/ServerSocket: use SocketDescriptor::GetPeerCredentials() 2025-01-29 17:56:26 +01:00
Max Kellermann
3710b54d43 event/ServerSocket: pass SocketDescriptor to get_remote_uid() 2025-01-29 17:56:26 +01:00
Max Kellermann
35dc1fc589 io/UniqueFileDescriptor: use AdoptTag in the constructors that adopt ownership 2025-01-23 16:57:39 +01:00
Max Kellermann
765a6a2f20 net/UniqueSocketDescriptor: use AdoptTag in the constructors that adopt ownership
This makes it a little bit harder to use the ownershop-adopting
constructors accidently.
2025-01-23 16:56:57 +01:00
Max Kellermann
9a8579d956 event/ServerSocket: do not close all listeners before rethrowing
If binding one address fails, we don't need to close all listeners.
For fatal errors, this will be done automatically and implicitly; and
for non-fatal errors (e.g. binding to the default port failed, but
there is an XDG listener), this closes the good listeners which are
supposed to be used.

Closes https://github.com/MusicPlayerDaemon/MPD/pull/2157
2024-12-04 14:25:42 +01:00
Max Kellermann
f807345022 event/Loop: use std::chrono::ceil()
Thanks to C++17, we don't need our custom implementation anymore.
2024-10-30 21:29:16 +01:00
Max Kellermann
bbbbf5f4bd event/MultiSocketMonitor: reschedule epoll/EPERM workaround forever
Fixes a regression by commit 3558317dc9 which caused the ALSA null
plugin to cease to work because the workaround timer was never rescheduled.
2024-07-25 20:16:53 +02:00
Max Kellermann
3558317dc9 event/MultiSocketMonitor: remove force-refresh on every iteration
libasound guarantees that the file descriptors never change for a
"prepared" PCM device, thus we can omit this defensive kludge.
2024-07-23 15:08:55 +02:00
Max Kellermann
4c4a3c8664 event/TimerList: use FineTimerEvent::GetDue()
Avoid accessing the private field from an inner class of the friend
class, because some compilers apparently don't like it (Apple clang).
2024-07-23 13:38:05 +02:00
Max Kellermann
9aa6b03ba8 event/MultiSocketMonitor: pass std::span to ReplaceSocketList() 2024-07-11 21:09:27 +02:00
Max Kellermann
45f92f0ef0 event/MultiSocketMonitor: fix lambda indent 2024-07-11 21:06:33 +02:00
Max Kellermann
23a3278b4e event/MultiSocketMonitor: make ctor protected and explicit 2024-07-11 21:05:11 +02:00
Max Kellermann
abb23ba894 event/EpollEvents: add mapping for EPOLLPRI 2024-06-25 20:28:34 +02:00
Max Kellermann
4fc3230fe6 event/Loop: use std::scoped_lock with implicit template parameter 2024-05-23 20:44:12 +02:00
Max Kellermann
4d3adaa557 event/SocketEvent: erase IMPLICIT_FLAGS in Cancel{Read,Write}()
Without this, calling CancelRead() after ScheduleRead() would leave
the HANGUP scheduled, and the caller could receive HANGUP events over
and over which are never properly handled, leading to a busy loop.

The semantics of this API are hard to get right, because the
IMPLICIT_FLAGS (a property of epoll) are somewhat weird.  But it seems
that this change repairs a side effect of the SocketEvent interface
that seemed counterintuitive.
2024-05-06 12:48:42 +02:00
Max Kellermann
1e4bf90c60 io, net, evnet: quote file names in error messages 2024-04-10 13:36:05 +02:00
Max Kellermann
1ee25b4234 event/TimerList: remove option NO_BOOST
Always use the new IntrusiveTreeSet class.
2024-04-03 21:30:59 +02:00
Max Kellermann
c5e607a310 event/TimerList: use IntrusiveTreeSet instead of boost::intrusive::multiset 2024-04-03 21:30:31 +02:00
Max Kellermann
c94c08c6b4 event/BufferedSocket: pass std::span to OnSocketInput() 2024-04-03 20:43:40 +02:00
Max Kellermann
b9daeef524 event/FineTimerEvent: add SetDue(), ScheduleCurrent() 2023-11-21 20:47:29 +01:00
Max Kellermann
9383ceac30 event/{Coarse,Fine}TimerEvent: add API docs 2023-11-21 20:47:25 +01:00
Max Kellermann
73708e7be7 event/TimerEvent: remove transitional header 2023-11-21 20:41:55 +01:00
Max Kellermann
57d9cffc42 event/PipeEvent: expose the EventPollBackendEvents constants 2023-11-02 10:48:21 +01:00
Max Kellermann
7c0b561a16 event/InotifyEvent: add method TryAddWatch() 2023-10-15 10:51:06 +02:00
Max Kellermann
491cc8f54d net/SocketDescriptor: add {Read,Write}NoWait()
It was surprising that Read() was non-blocking, but there was no
blocking version of it.  Let's make the non-blocking behavior explicit
and change Read() to be blocking.

In order to find existing callers easily with compiler errors, this
also refactors Read()/Write() to take a std::span parameter.
2023-09-27 11:39:55 +02:00
Max Kellermann
cad35a83fb io/FileDescriptor: add Read()/Write() overloads with std::span 2023-09-27 11:14:23 +02:00
Max Kellermann
21590e60e6 event/FullyBufferedSocket: pass std::span to DirectWrite() 2023-09-27 10:36:56 +02:00
Max Kellermann
fe69ad0861 event/BufferedSocket: pass std::span to DirectRead() 2023-09-27 10:34:50 +02:00
Max Kellermann
9daf8f6de5 event/BufferedSocket: use std::byte 2023-09-27 10:30:09 +02:00
Max Kellermann
1090cc964a event/Loop: relicense to BSD-2
This library has been initially developed at CM4all and eventually
published here:
 https://github.com/CM4all/libcommon/tree/master/src/event/

On this copy of it, there were only minor modifications by people
other than me, and these are below the copyright threshold; only
non-epoll backends (which remain under the GPL) were developed by
somebody else.
2023-09-26 15:47:09 +02:00
Max Kellermann
64647edbe1 lib/fmt/SocketAddressFormatter: new library 2023-09-19 11:22:39 +02:00
Max Kellermann
3d69f43cff event/Loop: include SocketEvent.hxx only if HAVE_THREADED_EVENT_LOOP 2023-09-16 22:55:04 +02:00
Max Kellermann
41b1931d91 event/Loop: move the poll_backend to the top
This is where all sockets are registered, so it should be initialized
first and destructed last.
2023-09-16 22:45:45 +02:00
Max Kellermann
26577d1301 io/uring/Queue: make Submit() virtual, Push() not
This allows submitting io_uring calls without an `Operation` instance
(fire & forget).  We'll do that for close().
2023-05-22 21:57:18 +02:00
Max Kellermann
9027e5c5bb Merge tag 'v0.23.13'
release v0.23.13
2023-05-22 19:52:08 +02:00
Max Kellermann
740cbe9e02 event/Loop: remove failing assert()
The `assert(!quit)` can fail if the `EventThread` gets stopped before
it enters `EventLoop::Run()`. There is a similar problem with `alive`,
which gets reset by `EventThread::Stop()`.

If that happens, then `EventLoop::Run()` should return immediately
without handling any events.
2023-05-22 18:14:25 +02:00
Max Kellermann
76497bd5f7 util/IntrusiveSortedList, event/TimerList: include cleanup 2023-04-06 10:24:53 +02:00
Max Kellermann
7a5f485cf8 event/ServerSocket: use class UniqueSocketDescriptor in SupportsIPv6() 2023-03-29 10:06:48 +02:00
Max Kellermann
6f7c7a2149 event/EpollBackend: add missing header guard 2023-03-21 11:00:41 +01:00