From 0c1a001622a06606b8a0c8ff4e168f0b6ffec3a6 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 6 Aug 2018 11:49:38 +0200 Subject: [PATCH] system/Event{FD,Pipe}: throw exception on error --- src/event/Loop.hxx | 4 ++++ src/system/EventFD.cxx | 4 ++-- src/system/EventFD.hxx | 5 +++-- src/system/EventPipe.hxx | 4 ++++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/event/Loop.hxx b/src/event/Loop.hxx index f578243d5..70028f385 100644 --- a/src/event/Loop.hxx +++ b/src/event/Loop.hxx @@ -116,7 +116,11 @@ class EventLoop final : SocketMonitor ThreadId thread = ThreadId::Null(); public: + /** + * Throws on error. + */ explicit EventLoop(ThreadId _thread); + EventLoop():EventLoop(ThreadId::GetCurrent()) {} ~EventLoop() noexcept; diff --git a/src/system/EventFD.cxx b/src/system/EventFD.cxx index 3c99a8ff5..92b5fd1bc 100644 --- a/src/system/EventFD.cxx +++ b/src/system/EventFD.cxx @@ -20,7 +20,7 @@ #include "config.h" #ifdef USE_EVENTFD #include "EventFD.hxx" -#include "system/FatalError.hxx" +#include "system/Error.hxx" #include "Compiler.h" #include @@ -29,7 +29,7 @@ EventFD::EventFD() { if (!fd.CreateEventFD(0)) - FatalSystemError("eventfd() failed"); + throw MakeErrno("eventfd() failed"); } bool diff --git a/src/system/EventFD.hxx b/src/system/EventFD.hxx index 2ec62fc68..306e5ab2f 100644 --- a/src/system/EventFD.hxx +++ b/src/system/EventFD.hxx @@ -25,13 +25,14 @@ /** * A class that wraps eventfd(). - * - * Errors in the constructor are fatal. */ class EventFD { UniqueFileDescriptor fd; public: + /** + * Throws on error. + */ EventFD(); int Get() const { diff --git a/src/system/EventPipe.hxx b/src/system/EventPipe.hxx index aa102c3f1..1a707bf23 100644 --- a/src/system/EventPipe.hxx +++ b/src/system/EventPipe.hxx @@ -31,7 +31,11 @@ class EventPipe { int fds[2]; public: + /** + * Throws on error. + */ EventPipe(); + ~EventPipe(); EventPipe(const EventPipe &other) = delete;