dovecot-2.2: lib-storage: Added mailbox_watch_extract_notify_fd()
dovecot at dovecot.org
dovecot at dovecot.org
Mon Aug 24 11:29:32 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/4da6efa3fd91
changeset: 18995:4da6efa3fd91
user: Timo Sirainen <tss at iki.fi>
date: Mon Aug 24 14:14:59 2015 +0300
description:
lib-storage: Added mailbox_watch_extract_notify_fd()
diffstat:
src/lib-storage/mailbox-watch.c | 49 +++++++++++++++++++++++++++++++++++++++++
src/lib-storage/mailbox-watch.h | 4 +++
2 files changed, 53 insertions(+), 0 deletions(-)
diffs (68 lines):
diff -r 3083424cafcd -r 4da6efa3fd91 src/lib-storage/mailbox-watch.c
--- a/src/lib-storage/mailbox-watch.c Mon Aug 24 14:02:52 2015 +0300
+++ b/src/lib-storage/mailbox-watch.c Mon Aug 24 14:14:59 2015 +0300
@@ -104,3 +104,52 @@
if (box->to_notify != NULL)
timeout_remove(&box->to_notify);
}
+
+static void notify_extract_callback(struct mailbox *box ATTR_UNUSED)
+{
+ i_unreached();
+}
+
+int mailbox_watch_extract_notify_fd(struct mailbox *box, const char **reason_r)
+{
+ struct ioloop *ioloop;
+ struct mailbox_notify_file *file;
+ struct io *io, *const *iop;
+ ARRAY(struct io *) temp_ios;
+ int ret;
+ bool failed = FALSE;
+
+ /* add all the notify IOs to a new ioloop. */
+ ioloop = io_loop_create();
+
+ t_array_init(&temp_ios, 8);
+ for (file = box->notify_files; file != NULL && !failed; file = file->next) {
+ switch (io_add_notify(file->path, notify_extract_callback, box, &io)) {
+ case IO_NOTIFY_ADDED:
+ array_append(&temp_ios, &io, 1);
+ break;
+ case IO_NOTIFY_NOTFOUND:
+ *reason_r = t_strdup_printf(
+ "%s not found - can't watch it", file->path);
+ failed = TRUE;
+ break;
+ case IO_NOTIFY_NOSUPPORT:
+ *reason_r = "Filesystem notifications not supported";
+ failed = TRUE;
+ break;
+ }
+ }
+ if (failed)
+ ret = -1;
+ else {
+ ret = io_loop_extract_notify_fd(ioloop);
+ if (ret == -1)
+ *reason_r = "Couldn't extra notify fd";
+ }
+ array_foreach(&temp_ios, iop) {
+ struct io *io = *iop;
+ io_remove(&io);
+ }
+ io_loop_destroy(&ioloop);
+ return ret;
+}
diff -r 3083424cafcd -r 4da6efa3fd91 src/lib-storage/mailbox-watch.h
--- a/src/lib-storage/mailbox-watch.h Mon Aug 24 14:02:52 2015 +0300
+++ b/src/lib-storage/mailbox-watch.h Mon Aug 24 14:14:59 2015 +0300
@@ -4,4 +4,8 @@
void mailbox_watch_add(struct mailbox *box, const char *path);
void mailbox_watch_remove_all(struct mailbox *box);
+/* Create a new temporary ioloop, add all the watches back and call
+ io_loop_extract_notify_fd() on it. Returns fd on success, -1 on error. */
+int mailbox_watch_extract_notify_fd(struct mailbox *box, const char **reason_r);
+
#endif
More information about the dovecot-cvs
mailing list