db/update/InotifySource: make errors non-fatal
This commit is contained in:
parent
184e8eca7c
commit
d2a8b1e8a5
@ -20,7 +20,6 @@
|
|||||||
#include "InotifySource.hxx"
|
#include "InotifySource.hxx"
|
||||||
#include "InotifyDomain.hxx"
|
#include "InotifyDomain.hxx"
|
||||||
#include "io/FileDescriptor.hxx"
|
#include "io/FileDescriptor.hxx"
|
||||||
#include "system/FatalError.hxx"
|
|
||||||
#include "system/Error.hxx"
|
#include "system/Error.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
@ -39,10 +38,17 @@ InotifySource::OnSocketReady([[maybe_unused]] unsigned flags) noexcept
|
|||||||
|
|
||||||
auto ifd = socket_event.GetFileDescriptor();
|
auto ifd = socket_event.GetFileDescriptor();
|
||||||
ssize_t nbytes = ifd.Read(buffer, sizeof(buffer));
|
ssize_t nbytes = ifd.Read(buffer, sizeof(buffer));
|
||||||
if (nbytes < 0)
|
if (nbytes <= 0) {
|
||||||
FatalSystemError("Failed to read from inotify");
|
if (nbytes < 0)
|
||||||
if (nbytes == 0)
|
FmtError(inotify_domain,
|
||||||
FatalError("end of file from inotify");
|
"Failed to read from inotify: {}",
|
||||||
|
strerror(errno));
|
||||||
|
else
|
||||||
|
LogError(inotify_domain,
|
||||||
|
"end of file from inotify");
|
||||||
|
socket_event.Cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const uint8_t *p = buffer, *const end = p + nbytes;
|
const uint8_t *p = buffer, *const end = p + nbytes;
|
||||||
|
|
||||||
@ -101,7 +107,8 @@ InotifySource::Remove(unsigned wd) noexcept
|
|||||||
auto ifd = socket_event.GetFileDescriptor();
|
auto ifd = socket_event.GetFileDescriptor();
|
||||||
int ret = inotify_rm_watch(ifd.Get(), wd);
|
int ret = inotify_rm_watch(ifd.Get(), wd);
|
||||||
if (ret < 0 && errno != EINVAL)
|
if (ret < 0 && errno != EINVAL)
|
||||||
LogErrno(inotify_domain, "inotify_rm_watch() has failed");
|
FmtError(inotify_domain, "inotify_rm_watch() has failed: {}",
|
||||||
|
strerror(errno));
|
||||||
|
|
||||||
/* EINVAL may happen here when the file has been deleted; the
|
/* EINVAL may happen here when the file has been deleted; the
|
||||||
kernel seems to auto-unregister deleted files */
|
kernel seems to auto-unregister deleted files */
|
||||||
|
Loading…
Reference in New Issue
Block a user