[dovecot-cvs] dovecot/src/lib-storage/index index-copy.c,1.21,1.22 index-expunge.c,1.12,1.13 index-fetch.c,1.33,1.34 index-messageset.c,1.7,1.8 index-search.c,1.42,1.43 index-status.c,1.19,1.20 index-storage.c,1.20,1.21 index-storage.h,1.22,1.23 Message-Id: <20021125190252.7E63E23997@danu.procontrol.fi>

cras at procontrol.fi cras at procontrol.fi
Mon Nov 25 21:02:52 EET 2002


Update of /home/cvs/dovecot/src/lib-storage/index
In directory danu:/tmp/cvs-serv2991/src/lib-storage/index

Modified Files:
	index-copy.c index-expunge.c index-fetch.c index-messageset.c 
	index-search.c index-status.c index-storage.c index-storage.h 
	index-sync.c index-update-flags.c 
Log Message:
Locking changes triggered a bit larger cleanup :) If we have to wait for a
lock longer, the client is now notified about it every 30 seconds. Also if
mailbox opening fails because of lock timeout, we won't overwrite the index
anymore. Finally user gets a clear error message about lock timeout instead
of "internal error".



Index: index-copy.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-copy.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- index-copy.c	20 Nov 2002 18:31:15 -0000	1.21
+++ index-copy.c	25 Nov 2002 19:02:50 -0000	1.22
@@ -66,8 +66,8 @@
 
 	if (ctx.copy_inside_mailbox) {
 		/* copying inside same mailbox */
-		if (!ibox->index->set_lock(ibox->index, MAIL_LOCK_EXCLUSIVE))
-			return mail_storage_set_index_error(ibox);
+		if (!index_storage_lock(ibox, MAIL_LOCK_EXCLUSIVE))
+			return FALSE;
 
 		lock_type = MAIL_LOCK_EXCLUSIVE;
 	} else {
@@ -84,8 +84,8 @@
 	failed = index_messageset_foreach(ibox, messageset, uidset,
 					  copy_func, &ctx) <= 0;
 
-	if (!ibox->index->set_lock(ibox->index, MAIL_LOCK_UNLOCK))
-		return mail_storage_set_index_error(ibox);
+	if (!index_storage_lock(ibox, MAIL_LOCK_UNLOCK))
+		return FALSE;
 
 	return !failed;
 }

Index: index-expunge.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-expunge.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- index-expunge.c	4 Nov 2002 04:47:40 -0000	1.12
+++ index-expunge.c	25 Nov 2002 19:02:50 -0000	1.13
@@ -51,8 +51,9 @@
 
 	if (seq <= ibox->synced_messages_count) {
 		if (notify) {
-			ibox->sync_callbacks.expunge(&ibox->box, seq,
-						     ibox->sync_context);
+			MailStorage *storage = ibox->box.storage;
+			storage->callbacks->expunge(&ibox->box, seq,
+						    storage->callback_context);
 		}
 		ibox->synced_messages_count--;
 	}
@@ -70,8 +71,8 @@
 		return FALSE;
 	}
 
-	if (!ibox->index->set_lock(ibox->index, MAIL_LOCK_EXCLUSIVE))
-		return mail_storage_set_index_error(ibox);
+	if (!index_storage_lock(ibox, MAIL_LOCK_EXCLUSIVE))
+		return FALSE;
 
 	if (!index_storage_sync_and_lock(ibox, FALSE, MAIL_LOCK_EXCLUSIVE))
 		return FALSE;
@@ -83,8 +84,8 @@
 	else
 		failed = !ibox->expunge_locked(ibox, notify);
 
-	if (!ibox->index->set_lock(ibox->index, MAIL_LOCK_UNLOCK))
-		return mail_storage_set_index_error(ibox);
+	if (!index_storage_lock(ibox, MAIL_LOCK_UNLOCK))
+		return FALSE;
 
 	return !failed;
 }

Index: index-fetch.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-fetch.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- index-fetch.c	13 Nov 2002 00:14:46 -0000	1.33
+++ index-fetch.c	25 Nov 2002 19:02:50 -0000	1.34
@@ -366,8 +366,8 @@
 
 	/* need exclusive lock to update the \Seen flags */
 	if (ctx.update_seen) {
-		if (!ibox->index->set_lock(ibox->index, MAIL_LOCK_EXCLUSIVE))
-			return mail_storage_set_index_error(ibox);
+		if (!index_storage_lock(ibox, MAIL_LOCK_EXCLUSIVE))
+			return FALSE;
 	}
 
 	if (!index_storage_sync_and_lock(ibox, TRUE, MAIL_LOCK_SHARED))
@@ -379,7 +379,7 @@
 		/* if all messages are already seen, there's no point in
 		   keeping exclusive lock */
 		ctx.update_seen = FALSE;
-		(void)ibox->index->set_lock(ibox->index, MAIL_LOCK_SHARED);
+		(void)index_storage_lock(ibox, MAIL_LOCK_SHARED);
 	}
 
 	ctx.box = box;
@@ -397,8 +397,8 @@
 				       fetch_data->uidset,
 				       index_fetch_mail, &ctx);
 
-	if (!ibox->index->set_lock(ibox->index, MAIL_LOCK_UNLOCK))
-		return mail_storage_set_index_error(ibox);
+	if (!index_storage_lock(ibox, MAIL_LOCK_UNLOCK))
+		return FALSE;
 
 	if (all_found != NULL)
 		*all_found = ret == 1 && !ctx.failed;

Index: index-messageset.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-messageset.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- index-messageset.c	23 Oct 2002 17:03:39 -0000	1.7
+++ index-messageset.c	25 Nov 2002 19:02:50 -0000	1.8
@@ -85,7 +85,8 @@
 		rec = index->next(index, rec);
 	}
 
-	if (rec == NULL && index->get_last_error(index) != NULL) {
+	if (rec == NULL &&
+	    index->get_last_error(index) != MAIL_INDEX_ERROR_NONE) {
 		/* error occured */
 		return -1;
 	}
@@ -230,7 +231,8 @@
 		rec = index->next(index, rec);
 	}
 
-	if (rec == NULL && index->get_last_error(index) != NULL) {
+	if (rec == NULL &&
+	    index->get_last_error(index) != MAIL_INDEX_ERROR_NONE) {
 		/* error occured */
 		return -1;
 	}

Index: index-search.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-search.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- index-search.c	13 Nov 2002 11:08:18 -0000	1.42
+++ index-search.c	25 Nov 2002 19:02:50 -0000	1.43
@@ -849,8 +849,8 @@
 	failed = !search_messages(ibox, charset, args, outbuf, uid_result);
 	o_buffer_send(outbuf, "\r\n", 2);
 
-	if (!ibox->index->set_lock(ibox->index, MAIL_LOCK_UNLOCK))
-		return mail_storage_set_index_error(ibox);
+	if (!index_storage_lock(ibox, MAIL_LOCK_UNLOCK))
+		return FALSE;
 
 	return !failed;
 }

Index: index-status.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-status.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- index-status.c	4 Nov 2002 04:47:40 -0000	1.19
+++ index-status.c	25 Nov 2002 19:02:50 -0000	1.20
@@ -79,8 +79,7 @@
 		return FALSE;
 
 	if (!index_storage_sync_modifylog(ibox, FALSE)) {
-		if (!ibox->index->set_lock(ibox->index, MAIL_LOCK_UNLOCK))
-			return mail_storage_set_index_error(ibox);
+		(void)index_storage_lock(ibox, MAIL_LOCK_UNLOCK);
 		return FALSE;
 	}
 
@@ -103,7 +102,7 @@
 	if (items & STATUS_CUSTOM_FLAGS)
 		get_custom_flags(ibox->index->custom_flags, status);
 
-	if (!ibox->index->set_lock(ibox->index, MAIL_LOCK_UNLOCK))
-		return mail_storage_set_index_error(ibox);
+	if (!index_storage_lock(ibox, MAIL_LOCK_UNLOCK))
+		return FALSE;
 	return TRUE;
 }

Index: index-storage.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-storage.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- index-storage.c	12 Nov 2002 05:27:30 -0000	1.20
+++ index-storage.c	25 Nov 2002 19:02:50 -0000	1.21
@@ -7,9 +7,12 @@
 #include "index-storage.h"
 
 #include <stdlib.h>
+#include <time.h>
 #include <unistd.h>
 #include <sys/stat.h>
 
+#define LOCK_NOTIFY_INTERVAL 30
+
 typedef struct _IndexList IndexList;
 
 struct _IndexList {
@@ -140,17 +143,91 @@
 	return ret;
 }
 
+static void lock_notify(MailLockNotifyType notify_type,
+			unsigned int secs_left, void *context)
+{
+	IndexMailbox *ibox = context;
+	MailStorage *storage = ibox->box.storage;
+	const char *str;
+	time_t now;
+
+	if ((secs_left % 15) != 0) {
+		/* update alarm() so that we get back here around the same
+		   time we want the next notify. also try to use somewhat
+		   rounded times. this affects only fcntl() locking, dotlock
+		   and flock() calls should be calling us constantly */
+		alarm(secs_left%15);
+	}
+
+	now = time(NULL);
+	if (now < ibox->next_lock_notify || secs_left < 15)
+		return;
+
+	ibox->next_lock_notify = now + LOCK_NOTIFY_INTERVAL;
+
+	switch (notify_type) {
+	case MAIL_LOCK_NOTIFY_MAILBOX_ABORT:
+		str = t_strdup_printf("Mailbox is locked, will abort in "
+				      "%u seconds", secs_left);
+		storage->callbacks->notify_no(&ibox->box, str,
+					      storage->callback_context);
+		break;
+	case MAIL_LOCK_NOTIFY_MAILBOX_OVERRIDE:
+		str = t_strdup_printf("Stale mailbox lock file detected, "
+				      "will override in %u seconds", secs_left);
+		storage->callbacks->notify_ok(&ibox->box, str,
+					      storage->callback_context);
+		break;
+	case MAIL_LOCK_NOTIFY_INDEX_ABORT:
+		str = t_strdup_printf("Mailbox index is locked, will abort in "
+				      "%u seconds", secs_left);
+		storage->callbacks->notify_no(&ibox->box, str,
+					      storage->callback_context);
+		break;
+	}
+}
+
+int index_storage_lock(IndexMailbox *ibox, MailLockType lock_type)
+{
+	int ret;
+
+	ibox->next_lock_notify = time(NULL) + LOCK_NOTIFY_INTERVAL;
+
+	/* we have to set/reset this every time, because the same index
+	   may be used by multiple IndexMailboxes. */
+	ibox->index->set_lock_notify_callback(ibox->index, lock_notify, ibox);
+	ret = ibox->index->set_lock(ibox->index, lock_type);
+	ibox->index->set_lock_notify_callback(ibox->index, NULL, NULL);
+
+	if (!ret)
+		return mail_storage_set_index_error(ibox);
+
+	return TRUE;
+}
+
 IndexMailbox *index_storage_init(MailStorage *storage, Mailbox *box,
 				 MailIndex *index, const char *name,
 				 int readonly, int fast)
 {
 	IndexMailbox *ibox;
-	MailIndexHeader *hdr;
-	unsigned int messages;
 
 	i_assert(name != NULL);
 
 	do {
+		ibox = i_new(IndexMailbox, 1);
+		ibox->box = *box;
+
+		ibox->box.storage = storage;
+		ibox->box.name = i_strdup(name);
+		ibox->box.readonly = readonly;
+		ibox->box.allow_custom_flags = TRUE;
+
+		ibox->index = index;
+		ibox->cache = imap_msgcache_alloc(&index_msgcache_iface);
+
+		ibox->next_lock_notify = time(NULL) + LOCK_NOTIFY_INTERVAL;
+		index->set_lock_notify_callback(index, lock_notify, ibox);
+
 		if (!index->opened) {
 			/* open the index first */
 			index->default_cache_fields =
@@ -161,33 +238,22 @@
 				break;
 		}
 
-		/* Get the synced messages count */
-		if (!index->set_lock(index, MAIL_LOCK_SHARED))
+		if (!ibox->index->set_lock(ibox->index, MAIL_LOCK_SHARED))
 			break;
 
-		hdr = mail_index_get_header(index);
-		messages = hdr->messages_count;
+		ibox->synced_messages_count =
+			mail_index_get_header(index)->messages_count;
 
-		if (!index->set_lock(index, MAIL_LOCK_UNLOCK))
+		if (!ibox->index->set_lock(ibox->index, MAIL_LOCK_UNLOCK))
 			break;
 
-		ibox = i_new(IndexMailbox, 1);
-		ibox->box = *box;
-
-		ibox->box.storage = storage;
-		ibox->box.name = i_strdup(name);
-		ibox->box.readonly = readonly;
-		ibox->box.allow_custom_flags = TRUE;
-
-		ibox->index = index;
-		ibox->cache = imap_msgcache_alloc(&index_msgcache_iface);
-		ibox->synced_messages_count = messages;
+		index->set_lock_notify_callback(index, NULL, NULL);
 
 		return ibox;
 	} while (0);
 
-	mail_storage_set_internal_error(storage);
-	index_storage_unref(index);
+	mail_storage_set_index_error(ibox);
+	index_storage_close(&ibox->box);
 	return NULL;
 }
 
@@ -197,32 +263,48 @@
 
 	index_mailbox_check_remove(ibox);
 	imap_msgcache_free(ibox->cache);
-	index_storage_unref(ibox->index);
+	if (ibox->index != NULL)
+		index_storage_unref(ibox->index);
+
 	i_free(box->name);
 	i_free(box);
 
 	return TRUE;
 }
 
-void index_storage_set_sync_callbacks(Mailbox *box,
-				      MailboxSyncCallbacks *callbacks,
-				      void *context)
+void index_storage_set_callbacks(MailStorage *storage,
+				 MailStorageCallbacks *callbacks,
+				 void *context)
 {
-	IndexMailbox *ibox = (IndexMailbox *) box;
-
-	memcpy(&ibox->sync_callbacks, callbacks, sizeof(MailboxSyncCallbacks));
-	ibox->sync_context = context;
+	memcpy(storage->callbacks, callbacks, sizeof(MailStorageCallbacks));
+	storage->callback_context = context;
 }
 
 int mail_storage_set_index_error(IndexMailbox *ibox)
 {
-	ibox->box.inconsistent =
-		ibox->index->is_inconsistency_error(ibox->index);
-
-	if (ibox->index->is_diskspace_error(ibox->index))
-		mail_storage_set_error(ibox->box.storage, "Out of disk space");
-	else
+	switch (ibox->index->get_last_error(ibox->index)) {
+	case MAIL_INDEX_ERROR_NONE:
+	case MAIL_INDEX_ERROR_INTERNAL:
 		mail_storage_set_internal_error(ibox->box.storage);
+		break;
+	case MAIL_INDEX_ERROR_INCONSISTENT:
+		ibox->box.inconsistent = TRUE;
+		break;
+	case MAIL_INDEX_ERROR_DISKSPACE:
+		mail_storage_set_error(ibox->box.storage, "Out of disk space");
+		break;
+	case MAIL_INDEX_ERROR_INDEX_LOCK_TIMEOUT:
+		mail_storage_set_error(ibox->box.storage, t_strconcat(
+			"Timeout while waiting for lock to index of mailbox ",
+			ibox->box.name, NULL));
+		break;
+	case MAIL_INDEX_ERROR_MAILBOX_LOCK_TIMEOUT:
+		mail_storage_set_error(ibox->box.storage, t_strconcat(
+			"Timeout while waiting for lock to mailbox ",
+			ibox->box.name, NULL));
+		break;
+	}
+
 	index_reset_error(ibox->index);
 	return FALSE;
 }

Index: index-storage.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-storage.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- index-storage.h	20 Nov 2002 18:31:15 -0000	1.22
+++ index-storage.h	25 Nov 2002 19:02:50 -0000	1.23
@@ -14,9 +14,6 @@
 	   exclusively locked */
 	int (*expunge_locked)(IndexMailbox *ibox, int notify);
 
-        MailboxSyncCallbacks sync_callbacks;
-	void *sync_context;
-
 	MailIndex *index;
 	ImapMessageCache *cache;
 
@@ -27,6 +24,8 @@
 
 	unsigned int synced_messages_count;
 
+	time_t next_lock_notify; /* temporary */
+
 	unsigned int sent_diskspace_warning:1;
 	unsigned int delay_save_unlocking:1; /* For COPYing inside mailbox */
 };
@@ -34,6 +33,7 @@
 extern ImapMessageCacheIface index_msgcache_iface;
 
 int mail_storage_set_index_error(IndexMailbox *ibox);
+int index_storage_lock(IndexMailbox *ibox, MailLockType lock_type);
 
 void index_storage_add(MailIndex *index);
 MailIndex *index_storage_lookup_ref(const char *path);
@@ -68,9 +68,9 @@
 void index_mailbox_check_remove(IndexMailbox *ibox);
 
 /* Mailbox methods: */
-void index_storage_set_sync_callbacks(Mailbox *box,
-				      MailboxSyncCallbacks *callbacks,
-				      void *context);
+void index_storage_set_callbacks(MailStorage *storage,
+				 MailStorageCallbacks *callbacks,
+				 void *context);
 int index_storage_copy(Mailbox *box, Mailbox *destbox,
 		       const char *messageset, int uidset);
 int index_storage_expunge(Mailbox *box, int notify);

Index: index-sync.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-sync.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- index-sync.c	12 Nov 2002 05:27:30 -0000	1.20
+++ index-sync.c	25 Nov 2002 19:02:50 -0000	1.21
@@ -9,9 +9,10 @@
 
 static void index_storage_sync_size(IndexMailbox *ibox)
 {
+	MailStorage *storage = ibox->box.storage;
 	unsigned int messages, recent;
 
-	if (ibox->sync_callbacks.new_messages == NULL)
+	if (storage->callbacks->new_messages == NULL)
 		return;
 
 	messages = ibox->index->get_header(ibox->index)->messages_count;
@@ -22,8 +23,8 @@
 
 		/* new messages in mailbox */
 		recent = index_storage_get_recent_count(ibox->index);
-		ibox->sync_callbacks.new_messages(&ibox->box, messages, recent,
-						  ibox->sync_context);
+		storage->callbacks->new_messages(&ibox->box, messages, recent,
+						 storage->callback_context);
 		ibox->synced_messages_count = messages;
 	}
 }
@@ -31,6 +32,7 @@
 int index_storage_sync_and_lock(IndexMailbox *ibox, int sync_size,
 				MailLockType data_lock_type)
 {
+	MailStorage *storage = ibox->box.storage;
 	MailIndex *index = ibox->index;
 	int changes, set_shared_lock;
 
@@ -40,17 +42,18 @@
 		/* reset every time it has worked */
 		ibox->sent_diskspace_warning = FALSE;
 	} else {
-		if (!index->is_diskspace_error(index)) {
-			(void)index->set_lock(index, MAIL_LOCK_UNLOCK);
+		if (index->get_last_error(index) !=
+		    MAIL_INDEX_ERROR_DISKSPACE) {
+			(void)index_storage_lock(ibox, MAIL_LOCK_UNLOCK);
 			return mail_storage_set_index_error(ibox);
 		}
 
 		/* notify client once about it */
 		if (!ibox->sent_diskspace_warning &&
-		    ibox->sync_callbacks.alert_no_diskspace != NULL) {
+		    storage->callbacks->alert_no_diskspace != NULL) {
 			ibox->sent_diskspace_warning = TRUE;
-			ibox->sync_callbacks.alert_no_diskspace(
-						&ibox->box, ibox->sync_context);
+			storage->callbacks->alert_no_diskspace(
+				&ibox->box, storage->callback_context);
 		}
 
 		index_reset_error(index);
@@ -59,8 +62,8 @@
 	if (set_shared_lock) {
 		/* just make sure we are locked, and that we drop our
 		   exclusive lock if it wasn't wanted originally */
-		if (!ibox->index->set_lock(ibox->index, MAIL_LOCK_SHARED)) {
-			(void)index->set_lock(index, MAIL_LOCK_UNLOCK);
+		if (!index_storage_lock(ibox, MAIL_LOCK_SHARED)) {
+			(void)index_storage_lock(ibox, MAIL_LOCK_UNLOCK);
 			return FALSE;
 		}
 	}
@@ -74,10 +77,10 @@
 
 	/* notify changes in custom flags */
 	if (mail_custom_flags_has_changes(index->custom_flags) &&
-	    ibox->sync_callbacks.new_custom_flags != NULL) {
-		ibox->sync_callbacks.new_custom_flags(&ibox->box,
+	    storage->callbacks->new_custom_flags != NULL) {
+		storage->callbacks->new_custom_flags(&ibox->box,
                 	mail_custom_flags_list_get(index->custom_flags),
-			MAIL_CUSTOM_FLAGS_COUNT, ibox->sync_context);
+			MAIL_CUSTOM_FLAGS_COUNT, storage->callback_context);
 	}
 
 	return TRUE;
@@ -88,7 +91,7 @@
 	const ModifyLogRecord *log1, *log2, *log, *first_flag_log;
 	MailIndexRecord *rec;
 	MailFlags flags;
-        MailboxSyncCallbacks *sc;
+        MailStorageCallbacks *sc;
 	void *sc_context;
 	const char **custom_flags;
 	unsigned int count1, count2, total_count, seq, seq_count, i, messages;
@@ -99,8 +102,8 @@
 					  &log1, &count1, &log2, &count2))
 		return mail_storage_set_index_error(ibox);
 
-	sc = &ibox->sync_callbacks;
-	sc_context = ibox->sync_context;
+	sc = ibox->box.storage->callbacks;
+	sc_context = ibox->box.storage->callback_context;
 
 	/* first show expunges. this makes it easier to deal with sequence
 	   numbers. */
@@ -222,8 +225,8 @@
 
 	index_storage_sync_size(ibox);
 
-	if (!ibox->index->set_lock(ibox->index, MAIL_LOCK_UNLOCK))
-		return mail_storage_set_index_error(ibox);
+	if (!index_storage_lock(ibox, MAIL_LOCK_UNLOCK))
+		return FALSE;
 
 	return ret;
 }

Index: index-update-flags.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-update-flags.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- index-update-flags.c	4 Nov 2002 04:47:40 -0000	1.14
+++ index-update-flags.c	25 Nov 2002 19:02:50 -0000	1.15
@@ -17,6 +17,7 @@
 		       void *context)
 {
 	UpdateContext *ctx = context;
+	MailStorage *storage;
 	MailFlags flags;
 	const char **custom_flags;
 
@@ -37,10 +38,11 @@
 	if (!index->update_flags(index, rec, idx_seq, flags, FALSE))
 		return FALSE;
 
+	storage = ctx->ibox->box.storage;
 	if (mail_custom_flags_has_changes(index->custom_flags)) {
-		ctx->ibox->sync_callbacks.new_custom_flags(&ctx->ibox->box,
+		storage->callbacks->new_custom_flags(&ctx->ibox->box,
 			mail_custom_flags_list_get(index->custom_flags),
-			MAIL_CUSTOM_FLAGS_COUNT, ctx->ibox->sync_context);
+			MAIL_CUSTOM_FLAGS_COUNT, storage->callback_context);
 	}
 
 	if (ctx->notify) {
@@ -48,11 +50,11 @@
 			flags |= MAIL_RECENT;
 
                 custom_flags = mail_custom_flags_list_get(index->custom_flags);
-		ctx->ibox->sync_callbacks.update_flags(&ctx->ibox->box,
-						       client_seq, rec->uid,
-						       flags, custom_flags,
-						       MAIL_CUSTOM_FLAGS_COUNT,
-						       ctx->ibox->sync_context);
+		storage->callbacks->update_flags(&ctx->ibox->box,
+						 client_seq, rec->uid,
+						 flags, custom_flags,
+						 MAIL_CUSTOM_FLAGS_COUNT,
+						 storage->callback_context);
 	}
 
 	return TRUE;
@@ -75,8 +77,8 @@
 	if (!index_mailbox_fix_custom_flags(ibox, &flags, custom_flags))
 		return FALSE;
 
-	if (!ibox->index->set_lock(ibox->index, MAIL_LOCK_EXCLUSIVE))
-		return mail_storage_set_index_error(ibox);
+	if (!index_storage_lock(ibox, MAIL_LOCK_EXCLUSIVE))
+		return FALSE;
 
 	if (!index_storage_sync_and_lock(ibox, TRUE, MAIL_LOCK_UNLOCK))
 		return FALSE;
@@ -89,8 +91,8 @@
 	ret = index_messageset_foreach(ibox, messageset, uidset,
 				       update_func, &ctx);
 
-	if (!ibox->index->set_lock(ibox->index, MAIL_LOCK_UNLOCK))
-		return mail_storage_set_index_error(ibox);
+	if (!index_storage_lock(ibox, MAIL_LOCK_UNLOCK))
+		return FALSE;
 
 	if (all_found != NULL)
 		*all_found = ret == 1;




More information about the dovecot-cvs mailing list