From: Timo Sirainen Date: Wed, 11 Aug 2010 16:09:51 +0000 (+0100) Subject: Improved "Inotify instance limit exceeded" error message. X-Git-Tag: 2.0.rc6~19 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fdb97244fa45c32c3593726c15aa69ce29bc7121;p=thirdparty%2Fdovecot%2Fcore.git Improved "Inotify instance limit exceeded" error message. --- diff --git a/src/lib/ioloop-notify-inotify.c b/src/lib/ioloop-notify-inotify.c index c5972d4558..a32b52e58d 100644 --- a/src/lib/ioloop-notify-inotify.c +++ b/src/lib/ioloop-notify-inotify.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -146,6 +147,23 @@ void io_loop_notify_remove(struct io *_io) io_remove(&ctx->event_io); } +static void ioloop_inotify_user_limit_exceeded(void) +{ + const struct passwd *pw; + const char *name; + uid_t uid = geteuid(); + + pw = getpwuid(uid); + if (pw == NULL) + name = t_strdup_printf("UID %s", dec2str(uid)); + else { + name = t_strdup_printf("%s (UID %s)", + dec2str(uid), pw->pw_name); + } + i_warning("Inotify instance limit for user %s exceeded, disabling. " + "Increase /proc/sys/fs/inotify/max_user_instances", name); +} + static struct ioloop_notify_handler_context *io_loop_notify_handler_init(void) { struct ioloop *ioloop = current_ioloop; @@ -158,11 +176,8 @@ static struct ioloop_notify_handler_context *io_loop_notify_handler_init(void) if (ctx->inotify_fd == -1) { if (errno != EMFILE) i_error("inotify_init() failed: %m"); - else { - i_warning("Inotify instance limit for user exceeded, " - "disabling. Increase " - "/proc/sys/fs/inotify/max_user_instances"); - } + else + ioloop_inotify_user_limit_exceeded(); ctx->disabled = TRUE; } else { fd_close_on_exec(ctx->inotify_fd, TRUE);