[dovecot-cvs] dovecot/src/lib ioloop-notify-dn.c, 1.4,
1.5 ioloop-notify-inotify.c, 1.1, 1.2
cras at dovecot.org
cras at dovecot.org
Tue Jul 12 18:53:58 EEST 2005
Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv2976/src/lib
Modified Files:
ioloop-notify-dn.c ioloop-notify-inotify.c
Log Message:
If dnotify/inotify isn't in kernel, handle the errors silently and without
leaking.
Index: ioloop-notify-dn.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/ioloop-notify-dn.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- ioloop-notify-dn.c 12 Jul 2005 15:40:33 -0000 1.4
+++ ioloop-notify-dn.c 12 Jul 2005 15:53:55 -0000 1.5
@@ -16,6 +16,7 @@
struct ioloop_notify_handler_context {
struct io *event_io;
+ int disabled;
};
static int event_pipe[2] = { -1, -1 };
@@ -67,12 +68,12 @@
if ((condition & IO_FILE_NOTIFY) != 0)
return NULL;
- if (ctx->event_io == NULL) {
- ctx->event_io =
- io_add(event_pipe[0], IO_READ, event_callback, ioloop);
- }
-
if (fcntl(fd, F_SETSIG, SIGRTMIN) < 0) {
+ if (errno == EINVAL) {
+ /* dnotify not in kernel. disable it. */
+ ctx->disabled = TRUE;
+ return NULL;
+ }
i_error("fcntl(F_SETSIG) failed: %m");
return FALSE;
}
@@ -83,6 +84,11 @@
return FALSE;
}
+ if (ctx->event_io == NULL) {
+ ctx->event_io =
+ io_add(event_pipe[0], IO_READ, event_callback, ioloop);
+ }
+
io = p_new(ioloop->pool, struct io, 1);
io->fd = fd;
io->condition = condition;
@@ -101,6 +107,9 @@
ioloop->notify_handler_context;
struct io **io_p;
+ if (ctx->disabled)
+ return;
+
for (io_p = &ioloop->notifys; *io_p != NULL; io_p = &(*io_p)->next) {
if (*io_p == io) {
*io_p = io->next;
Index: ioloop-notify-inotify.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/ioloop-notify-inotify.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ioloop-notify-inotify.c 12 Jul 2005 15:40:33 -0000 1.1
+++ ioloop-notify-inotify.c 12 Jul 2005 15:53:55 -0000 1.2
@@ -94,17 +94,13 @@
ioloop->notify_handler_context;
struct io *io;
struct inotify_watch_request req;
- int added = FALSE;
int watchdescriptor;
if ((condition & IO_FILE_NOTIFY) != 0)
return NULL;
- if (ctx->event_io == NULL) {
- added = TRUE;
- ctx->event_io = io_add(ctx->inotify_fd, IO_READ,
- event_callback, ioloop);
- }
+ if (ctx->disabled)
+ return NULL;
/* now set up the notification request and shoot it off */
req.fd = fd;
@@ -112,14 +108,16 @@
watchdescriptor = ioctl(ctx->inotify_fd, INOTIFY_WATCH, &req);
if (watchdescriptor < 0) {
+ ctx->disabled = TRUE;
i_error("ioctl(INOTIFY_WATCH) failed: %m");
- if (added) {
- io_remove(ctx->event_io);
- ctx->event_io = NULL;
- }
return NULL;
}
+ if (ctx->event_io == NULL) {
+ ctx->event_io = io_add(ctx->inotify_fd, IO_READ,
+ event_callback, ioloop);
+ }
+
io = p_new(ioloop->pool, struct io, 1);
io->fd = fd;
io->condition = condition;
@@ -139,6 +137,9 @@
ioloop->notify_handler_context;
struct io **io_p;
+ if (ctx->disabled)
+ return;
+
for (io_p = &ioloop->notifys; *io_p != NULL; io_p = &(*io_p)->next) {
if (*io_p == io) {
*io_p = io->next;
@@ -165,8 +166,10 @@
i_new(struct ioloop_notify_handler_context, 1);
ctx->inotify_fd = open("/dev/inotify", O_RDONLY);
- if (ctx->inotify_fd < 0)
- i_fatal("open(/dev/inotify) failed: %m");
+ if (ctx->inotify_fd < 0) {
+ ctx->disabled = TRUE;
+ return;
+ }
ctx->buf = buffer_create_dynamic(default_pool, INITIAL_INOTIFY_BUFLEN);
}
More information about the dovecot-cvs
mailing list