dovecot-2.2: lib: Log notify IO leaks when ioloop is destroyed.
dovecot at dovecot.org
dovecot at dovecot.org
Wed Aug 19 18:32:43 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/818c1a77c025
changeset: 18985:818c1a77c025
user: Timo Sirainen <tss at iki.fi>
date: Wed Aug 19 21:31:56 2015 +0300
description:
lib: Log notify IO leaks when ioloop is destroyed.
diffstat:
src/lib/ioloop-notify-inotify.c | 10 ++++++++++
src/lib/ioloop-notify-kqueue.c | 26 ++++++++++++++++++++++++--
2 files changed, 34 insertions(+), 2 deletions(-)
diffs (98 lines):
diff -r d26178d0557a -r 818c1a77c025 src/lib/ioloop-notify-inotify.c
--- a/src/lib/ioloop-notify-inotify.c Wed Aug 19 21:24:50 2015 +0300
+++ b/src/lib/ioloop-notify-inotify.c Wed Aug 19 21:31:56 2015 +0300
@@ -193,6 +193,16 @@
struct ioloop_notify_handler_context *ctx =
ioloop->notify_handler_context;
+ while (ctx->fd_ctx.notifies != NULL) {
+ struct io_notify *io = ctx->fd_ctx.notifies;
+ struct io *_io = &io->io;
+
+ i_warning("I/O notify leak: %p (line %u, fd %d)",
+ (void *)_io->callback,
+ _io->source_linenum, io->fd);
+ io_remove(&_io);
+ }
+
if (ctx->inotify_fd != -1) {
if (close(ctx->inotify_fd) < 0)
i_error("close(inotify) failed: %m");
diff -r d26178d0557a -r 818c1a77c025 src/lib/ioloop-notify-kqueue.c
--- a/src/lib/ioloop-notify-kqueue.c Wed Aug 19 21:24:50 2015 +0300
+++ b/src/lib/ioloop-notify-kqueue.c Wed Aug 19 21:31:56 2015 +0300
@@ -10,6 +10,7 @@
#ifdef IOLOOP_NOTIFY_KQUEUE
#include "ioloop-private.h"
+#include "llist.h"
#include "fd-close-on-exec.h"
#include <unistd.h>
#include <fcntl.h>
@@ -32,13 +33,23 @@
struct io io;
int refcount;
int fd;
+ struct io_notify *prev, *next;
};
struct ioloop_notify_handler_context {
int kq;
struct io *event_io;
+ struct io_notify *notifies;
};
+static void
+io_loop_notify_free(struct ioloop_notify_handler_context *ctx,
+ struct io_notify *io)
+{
+ DLLIST_REMOVE(&ctx->notifies, io);
+ i_free(io);
+}
+
static void event_callback(struct ioloop_notify_handler_context *ctx)
{
struct io_notify *io;
@@ -74,7 +85,7 @@
io_loop_call_io(&io->io);
if (--io->refcount == 0)
- i_free(io);
+ io_loop_notify_free(ctx, io);
}
}
@@ -96,6 +107,16 @@
struct ioloop_notify_handler_context *ctx =
ioloop->notify_handler_context;
+ while (ctx->notifies != NULL) {
+ struct io_notify *io = ctx->notifies;
+ struct io *_io = &io->io;
+
+ i_warning("I/O notify leak: %p (line %u, fd %d)",
+ (void *)_io->callback,
+ _io->source_linenum, io->fd);
+ io_remove(&_io);
+ }
+
if (ctx->event_io)
io_remove(&ctx->event_io);
if (close(ctx->kq) < 0)
@@ -153,6 +174,7 @@
ctx->event_io = io_add(ctx->kq, IO_READ, event_callback,
io->io.ioloop->notify_handler_context);
}
+ DLLIST_PREPEND(&ctx->notifies, io);
*io_r = &io->io;
return IO_NOTIFY_ADDED;
}
@@ -172,7 +194,7 @@
io->fd = -1;
if (--io->refcount == 0)
- i_free(io);
+ io_loop_notify_free(ctx, io);
}
#endif
More information about the dovecot-cvs
mailing list