|
|
8aada9 |
From 0c5711f9bae1cb46d4cd3fbe5d86d8688087be13 Mon Sep 17 00:00:00 2001
|
|
|
8aada9 |
From: Alexey Tikhonov <atikhono@redhat.com>
|
|
|
8aada9 |
Date: Fri, 12 Jun 2020 20:45:23 +0200
|
|
|
8aada9 |
Subject: [PATCH] util/inotify: fixed bug in inotify event processing
|
|
|
8aada9 |
MIME-Version: 1.0
|
|
|
8aada9 |
Content-Type: text/plain; charset=UTF-8
|
|
|
8aada9 |
Content-Transfer-Encoding: 8bit
|
|
|
8aada9 |
|
|
|
8aada9 |
Error was spotted with the help of the following warning:
|
|
|
8aada9 |
```
|
|
|
8aada9 |
Error: CLANG_WARNING:
|
|
|
8aada9 |
sssd-2.3.1/src/util/inotify.c:327:21: warning: Value stored to 'rewatch' is never read
|
|
|
8aada9 |
# rewatch = true;
|
|
|
8aada9 |
# ^ ~~~~
|
|
|
8aada9 |
```
|
|
|
8aada9 |
|
|
|
8aada9 |
First part of the issue was that EAGAIN returned by the process_dir_event()
|
|
|
8aada9 |
didn't trigger snotify_rewatch() (as suggested by the comments).
|
|
|
8aada9 |
Fixing this part is already enough to resolve issue #1031 (as it was
|
|
|
8aada9 |
reported).
|
|
|
8aada9 |
|
|
|
8aada9 |
Another part of the issue was that process_file_event() return code wasn't
|
|
|
8aada9 |
checked against EAGAIN (again, as suggested by the DEBUG message).
|
|
|
8aada9 |
Strictly speaking, I'm not sure if this part is really required or
|
|
|
8aada9 |
if processing DIR events would cover all cases, but rebuilding watches
|
|
|
8aada9 |
on IN_IGNORED won't hurt.
|
|
|
8aada9 |
|
|
|
8aada9 |
Resolves: https://github.com/SSSD/sssd/issues/1031
|
|
|
8aada9 |
|
|
|
8aada9 |
Reviewed-by: Tomáš Halman <thalman@redhat.com>
|
|
|
8aada9 |
---
|
|
|
8aada9 |
src/util/inotify.c | 30 +++++++++++++-----------------
|
|
|
8aada9 |
1 file changed, 13 insertions(+), 17 deletions(-)
|
|
|
8aada9 |
|
|
|
8aada9 |
diff --git a/src/util/inotify.c b/src/util/inotify.c
|
|
|
8aada9 |
index cf3e3d84d..a3c33eddb 100644
|
|
|
8aada9 |
--- a/src/util/inotify.c
|
|
|
8aada9 |
+++ b/src/util/inotify.c
|
|
|
8aada9 |
@@ -286,7 +286,7 @@ static void snotify_internal_cb(struct tevent_context *ev,
|
|
|
8aada9 |
struct snotify_ctx *snctx;
|
|
|
8aada9 |
ssize_t len;
|
|
|
8aada9 |
errno_t ret;
|
|
|
8aada9 |
- bool rewatch;
|
|
|
8aada9 |
+ bool rewatch = false;
|
|
|
8aada9 |
|
|
|
8aada9 |
snctx = talloc_get_type(data, struct snotify_ctx);
|
|
|
8aada9 |
if (snctx == NULL) {
|
|
|
8aada9 |
@@ -305,7 +305,7 @@ static void snotify_internal_cb(struct tevent_context *ev,
|
|
|
8aada9 |
} else {
|
|
|
8aada9 |
DEBUG(SSSDBG_TRACE_INTERNAL, "All inotify events processed\n");
|
|
|
8aada9 |
}
|
|
|
8aada9 |
- return;
|
|
|
8aada9 |
+ break;
|
|
|
8aada9 |
}
|
|
|
8aada9 |
|
|
|
8aada9 |
if ((size_t) len < sizeof(struct inotify_event)) {
|
|
|
8aada9 |
@@ -325,26 +325,22 @@ static void snotify_internal_cb(struct tevent_context *ev,
|
|
|
8aada9 |
|
|
|
8aada9 |
if (snctx->wctx->dir_wd == in_event->wd) {
|
|
|
8aada9 |
ret = process_dir_event(snctx, in_event);
|
|
|
8aada9 |
- if (ret == EAGAIN) {
|
|
|
8aada9 |
- rewatch = true;
|
|
|
8aada9 |
- /* Continue with the loop and read all the events from
|
|
|
8aada9 |
- * this descriptor first, then rewatch when done
|
|
|
8aada9 |
- */
|
|
|
8aada9 |
- } else if (ret != EOK) {
|
|
|
8aada9 |
- DEBUG(SSSDBG_MINOR_FAILURE,
|
|
|
8aada9 |
- "Failed to process inotify event\n");
|
|
|
8aada9 |
- continue;
|
|
|
8aada9 |
- }
|
|
|
8aada9 |
} else if (snctx->wctx->file_wd == in_event->wd) {
|
|
|
8aada9 |
ret = process_file_event(snctx, in_event);
|
|
|
8aada9 |
- if (ret != EOK) {
|
|
|
8aada9 |
- DEBUG(SSSDBG_MINOR_FAILURE,
|
|
|
8aada9 |
- "Failed to process inotify event\n");
|
|
|
8aada9 |
- continue;
|
|
|
8aada9 |
- }
|
|
|
8aada9 |
} else {
|
|
|
8aada9 |
DEBUG(SSSDBG_MINOR_FAILURE,
|
|
|
8aada9 |
"Unknown watch %d\n", in_event->wd);
|
|
|
8aada9 |
+ ret = EOK;
|
|
|
8aada9 |
+ }
|
|
|
8aada9 |
+
|
|
|
8aada9 |
+ if (ret == EAGAIN) {
|
|
|
8aada9 |
+ rewatch = true;
|
|
|
8aada9 |
+ /* Continue with the loop and read all the events from
|
|
|
8aada9 |
+ * this descriptor first, then rewatch when done
|
|
|
8aada9 |
+ */
|
|
|
8aada9 |
+ } else if (ret != EOK) {
|
|
|
8aada9 |
+ DEBUG(SSSDBG_MINOR_FAILURE,
|
|
|
8aada9 |
+ "Failed to process inotify event\n");
|
|
|
8aada9 |
}
|
|
|
8aada9 |
}
|
|
|
8aada9 |
}
|
|
|
8aada9 |
--
|
|
|
8aada9 |
2.21.3
|
|
|
8aada9 |
|