changeset 7457:940641318f12 HEAD

Renamed IO_NOTIFY_DISABLED to IO_NOTIFY_NOSUPPORT. IO_NOTIFY_NOSUPPORT is now also given by dnotify when trying to listen for files. Fixes busy looping with dnotify when waiting for dotlock to get deleted.
author Timo Sirainen <tss@iki.fi>
date Thu, 24 Apr 2008 16:59:19 +0300
parents 8af71985e97b
children 43674a726a92
files src/lib/file-dotlock.c src/lib/ioloop-notify-dn.c src/lib/ioloop-notify-inotify.c src/lib/ioloop-notify-kqueue.c src/lib/ioloop-notify-none.c src/lib/ioloop.h
diffstat 6 files changed, 13 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib/file-dotlock.c	Thu Apr 24 16:56:10 2008 +0300
+++ b/src/lib/file-dotlock.c	Thu Apr 24 16:59:19 2008 +0300
@@ -429,7 +429,7 @@
 		/* the lock file doesn't exist anymore, don't sleep */
 		io_loop_destroy(&ioloop);
 		return;
-	case IO_NOTIFY_DISABLED:
+	case IO_NOTIFY_NOSUPPORT:
 		/* listening for files not supported */
 		io_loop_destroy(&ioloop);
 		lock_info->use_io_notify = FALSE;
--- a/src/lib/ioloop-notify-dn.c	Thu Apr 24 16:56:10 2008 +0300
+++ b/src/lib/ioloop-notify-dn.c	Thu Apr 24 16:59:19 2008 +0300
@@ -84,7 +84,7 @@
 	if (ctx == NULL)
 		ctx = io_loop_notify_handler_init();
 	if (ctx->disabled)
-		return IO_NOTIFY_DISABLED;
+		return IO_NOTIFY_NOSUPPORT;
 
 	fd = open(path, O_RDONLY);
 	if (fd == -1) {
@@ -101,24 +101,22 @@
 			i_error("fcntl(F_SETSIG) failed: %m");
 		ctx->disabled = TRUE;
 		(void)close(fd);
-		return IO_NOTIFY_DISABLED;
+		return IO_NOTIFY_NOSUPPORT;
 	}
 	if (fcntl(fd, F_NOTIFY, DN_CREATE | DN_DELETE | DN_RENAME |
 		  DN_MULTISHOT) < 0) {
 		if (errno == ENOTDIR) {
 			/* we're trying to add dnotify to a non-directory fd.
 			   fail silently. */
-			ret = IO_NOTIFY_NOTFOUND;
 		} else {
 			/* dnotify not in kernel. disable it. */
 			if (errno != EINVAL)
 				i_error("fcntl(F_NOTIFY) failed: %m");
 			ctx->disabled = TRUE;
-			ret = IO_NOTIFY_DISABLED;
 		}
 		(void)fcntl(fd, F_SETSIG, 0);
 		(void)close(fd);
-		return ret;
+		return IO_NOTIFY_NOSUPPORT;
 	}
 
 	if (ctx->event_io == NULL) {
--- a/src/lib/ioloop-notify-inotify.c	Thu Apr 24 16:56:10 2008 +0300
+++ b/src/lib/ioloop-notify-inotify.c	Thu Apr 24 16:59:19 2008 +0300
@@ -95,7 +95,7 @@
 	if (ctx == NULL)
 		ctx = io_loop_notify_handler_init();
 	if (ctx->disabled)
-		return IO_NOTIFY_DISABLED;
+		return IO_NOTIFY_NOSUPPORT;
 
 	wd = inotify_add_watch(ctx->inotify_fd, path,
 			       IN_CREATE | IN_DELETE | IN_DELETE_SELF |
@@ -107,7 +107,7 @@
 			return IO_NOTIFY_NOTFOUND;
 
 		ctx->disabled = TRUE;
-		return IO_NOTIFY_DISABLED;
+		return IO_NOTIFY_NOSUPPORT;
 	}
 
 	if (ctx->event_io == NULL) {
--- a/src/lib/ioloop-notify-kqueue.c	Thu Apr 24 16:56:10 2008 +0300
+++ b/src/lib/ioloop-notify-kqueue.c	Thu Apr 24 16:59:19 2008 +0300
@@ -140,7 +140,7 @@
 		i_error("kevent(%d, %s) for notify failed: %m", fd, path);
 		(void)close(fd);
 		i_free(io);
-		return IO_NOTIFY_DISABLED;
+		return IO_NOTIFY_NOSUPPORT;
 	}
 
 	if (ctx->event_io == NULL) {
--- a/src/lib/ioloop-notify-none.c	Thu Apr 24 16:56:10 2008 +0300
+++ b/src/lib/ioloop-notify-none.c	Thu Apr 24 16:59:19 2008 +0300
@@ -12,7 +12,7 @@
 	      void *context ATTR_UNUSED, struct io **io_r)
 {
 	*io_r = NULL;
-	return IO_NOTIFY_DISABLED;
+	return IO_NOTIFY_NOSUPPORT;
 }
 
 void io_loop_notify_remove(struct ioloop *ioloop ATTR_UNUSED,
--- a/src/lib/ioloop.h	Thu Apr 24 16:56:10 2008 +0300
+++ b/src/lib/ioloop.h	Thu Apr 24 16:59:19 2008 +0300
@@ -20,9 +20,13 @@
 };
 
 enum io_notify_result {
+	/* Notify added successfully */
 	IO_NOTIFY_ADDED,
+	/* Specified file doesn't exist, can't wait on it */
 	IO_NOTIFY_NOTFOUND,
-	IO_NOTIFY_DISABLED
+	/* Can't add notify for specified file. Main reasons for this:
+	   a) No notify support at all, b) Only directory notifies supported */
+	IO_NOTIFY_NOSUPPORT
 };
 
 typedef void io_callback_t(void *context);