aboutsummaryrefslogtreecommitdiffstats
path: root/src/db
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-03-03 17:03:21 +0100
committerMax Kellermann <max@duempel.org>2015-03-03 17:14:30 +0100
commit40a587bbaff38bb0b60313c24b94e2ecd53b181c (patch)
treed72c9db82e0db482ebe054119460b506433e9d05 /src/db
parent818d729d8b60a682e267ac408c710f5851389d79 (diff)
downloadmpd-40a587bbaff38bb0b60313c24b94e2ecd53b181c.tar.gz
mpd-40a587bbaff38bb0b60313c24b94e2ecd53b181c.tar.xz
mpd-40a587bbaff38bb0b60313c24b94e2ecd53b181c.zip
system/FileDescriptor: new wrapper class for a file descriptor
Diffstat (limited to 'src/db')
-rw-r--r--src/db/update/InotifySource.cxx10
-rw-r--r--src/db/update/InotifySource.hxx4
2 files changed, 8 insertions, 6 deletions
diff --git a/src/db/update/InotifySource.cxx b/src/db/update/InotifySource.cxx
index d0ac5b779..b084dd60a 100644
--- a/src/db/update/InotifySource.cxx
+++ b/src/db/update/InotifySource.cxx
@@ -21,7 +21,7 @@
#include "InotifySource.hxx"
#include "InotifyDomain.hxx"
#include "util/Error.hxx"
-#include "system/fd_util.h"
+#include "system/FileDescriptor.hxx"
#include "system/FatalError.hxx"
#include "Log.hxx"
@@ -72,8 +72,8 @@ InotifySource::OnSocketReady(gcc_unused unsigned flags)
inline
InotifySource::InotifySource(EventLoop &_loop,
mpd_inotify_callback_t _callback, void *_ctx,
- int _fd)
- :SocketMonitor(_fd, _loop),
+ FileDescriptor _fd)
+ :SocketMonitor(_fd.Get(), _loop),
callback(_callback), callback_ctx(_ctx)
{
ScheduleRead();
@@ -85,8 +85,8 @@ InotifySource::Create(EventLoop &loop,
mpd_inotify_callback_t callback, void *callback_ctx,
Error &error)
{
- int fd = inotify_init_cloexec();
- if (fd < 0) {
+ FileDescriptor fd;
+ if (!fd.CreateInotify()) {
error.SetErrno("inotify_init() has failed");
return nullptr;
}
diff --git a/src/db/update/InotifySource.hxx b/src/db/update/InotifySource.hxx
index 0eb69719b..e662e5a04 100644
--- a/src/db/update/InotifySource.hxx
+++ b/src/db/update/InotifySource.hxx
@@ -24,6 +24,7 @@
#include "Compiler.h"
class Error;
+class FileDescriptor;
typedef void (*mpd_inotify_callback_t)(int wd, unsigned mask,
const char *name, void *ctx);
@@ -33,7 +34,8 @@ class InotifySource final : private SocketMonitor {
void *callback_ctx;
InotifySource(EventLoop &_loop,
- mpd_inotify_callback_t callback, void *ctx, int fd);
+ mpd_inotify_callback_t callback, void *ctx,
+ FileDescriptor fd);
public:
~InotifySource() {