plugins: pidfile: Simplify and clean up developer debug messages

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2020-02-29 17:04:27 +01:00
1 parent f7d5b588c9
commit 69016bb8f5
1 file changed
-15
-15
View File
@@ -55,7 +55,6 @@ static int watcher_add(struct context *ctx, char *path)
char *ptr; char *ptr;
int fd; int fd;
_d("pidfile: Adding new watcher for path %s", path);
ptr = strstr(path, "run/"); ptr = strstr(path, "run/");
if (ptr) { if (ptr) {
char *slash; char *slash;
@@ -94,7 +93,6 @@ static int watcher_add(struct context *ctx, char *path)
static int watcher_del(struct context *ctx, struct wd_entry *wde) static int watcher_del(struct context *ctx, struct wd_entry *wde)
{ {
_d("pidfile: Removing watcher for removed path %s", wde->path);
TAILQ_REMOVE(&ctx->wd_list, wde, link); TAILQ_REMOVE(&ctx->wd_list, wde, link);
inotify_rm_watch(ctx->fd, wde->fd); inotify_rm_watch(ctx->fd, wde->fd);
free(wde->path); free(wde->path);
@@ -108,15 +106,12 @@ static void update_conds(char *name, uint32_t mask)
svc_t *svc; svc_t *svc;
char cond[MAX_COND_LEN]; char cond[MAX_COND_LEN];
_d("name: %s", name);
svc = svc_find_by_pidfile(name); svc = svc_find_by_pidfile(name);
if (!svc) { if (!svc) {
_d("pidfile: No matching svc for %s", name); _d("pidfile: No matching svc for %s", name);
return; return;
} }
_d("Event %s for svc %s", name, svc->cmd);
mkcond(svc, cond, sizeof(cond)); mkcond(svc, cond, sizeof(cond));
if (mask & (IN_CREATE | IN_ATTRIB | IN_MODIFY | IN_MOVED_TO)) { if (mask & (IN_CREATE | IN_ATTRIB | IN_MODIFY | IN_MOVED_TO)) {
svc_started(svc); svc_started(svc);
@@ -172,7 +167,6 @@ static void handle_dir(struct context *ctx, struct wd_entry *wde, char *name, in
return; return;
} }
snprintf(path, plen, "%s/%s", wde->path, name); snprintf(path, plen, "%s/%s", wde->path, name);
_d("pidfile: path is %s", path);
TAILQ_FOREACH(wde, &ctx->wd_list, link) { TAILQ_FOREACH(wde, &ctx->wd_list, link) {
if (!strcmp(wde->path, path)) { if (!strcmp(wde->path, path)) {
@@ -210,14 +204,12 @@ static void pidfile_callback(void *arg, int fd, int events)
return; return;
} }
_d("pidfile: Entering ... reading %zu bytes into ev_buf[]", buflen - 1);
sz = read(fd, buf, buflen - 1); sz = read(fd, buf, buflen - 1);
if (sz <= 0) { if (sz <= 0) {
_pe("invalid inotify event"); _pe("invalid inotify event");
goto done; goto done;
} }
buf[sz] = 0; buf[sz] = 0;
_d("pidfile: Read %zd bytes, processing ...", sz);
off = 0; off = 0;
for (off = 0; off < sz; off += sizeof(*ev) + ev->len) { for (off = 0; off < sz; off += sizeof(*ev) + ev->len) {
@@ -225,7 +217,6 @@ static void pidfile_callback(void *arg, int fd, int events)
ev = (struct inotify_event *)&buf[off]; ev = (struct inotify_event *)&buf[off];
_d("pidfile: path %s, event: 0x%08x", ev->name, ev->mask);
if (!ev->mask) if (!ev->mask)
continue; continue;
@@ -240,11 +231,6 @@ static void pidfile_callback(void *arg, int fd, int events)
continue; continue;
} }
if (ev->mask & IN_DELETE) {
_d("pidfile %s/%s removed ...", wde->path, ev->name);
continue;
}
if (ev->mask & (IN_CREATE | IN_ATTRIB | IN_MODIFY | IN_MOVED_TO)) if (ev->mask & (IN_CREATE | IN_ATTRIB | IN_MODIFY | IN_MOVED_TO))
update_conds(ev->name, ev->mask); update_conds(ev->name, ev->mask);
} }
@@ -305,7 +291,6 @@ static void pidfile_init(void *arg)
TAILQ_INIT(&pidfile_ctx.wd_list); TAILQ_INIT(&pidfile_ctx.wd_list);
if (watcher_add(&pidfile_ctx, path)) if (watcher_add(&pidfile_ctx, path))
close(pidfile_ctx.fd); close(pidfile_ctx.fd);
_d("pidfile monitor active");
} }
static struct context pidfile_ctx; static struct context pidfile_ctx;