bneradt commented on code in PR #12274:
URL: https://github.com/apache/trafficserver/pull/12274#discussion_r2125561506


##########
plugins/healthchecks/healthchecks.cc:
##########
@@ -166,25 +166,54 @@ setup_watchers(int fd)
 /* Separate thread to monitor status files for reload */
 #define INOTIFY_BUFLEN (1024 * sizeof(struct inotify_event))
 
+/** Determine whether @a event applies to the @a finfo configured file. */
+static bool
+event_matches_config(struct inotify_event *event, HCFileInfo *finfo)
+{
+  if (!finfo || !event) {
+    return false;
+  }
+  if (event->wd == finfo->wd) {
+    // Easy: the event is for this configured file we are watching.
+    return true;
+  }
+  if (event->wd != finfo->dir->wd) {
+    // The event is not for this file, nor for the parent directory. No match.
+    return false;
+  }
+
+  // The event applies to a change in a directory that contains files we are
+  // configured to watch. Does the directory event apply to this file?
+
+  if (!finfo->basename || finfo->basename_len <= 0) {
+    // This configured finfo is not for a specific file.
+    return false;
+  }
+  if (strnlen(event->name, NAME_MAX) != finfo->basename_len) {
+    return false;
+  }

Review Comment:
   The addition of this length check is the functional change. This is the fix 
for the incorrect matching bug described in the description.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to