[dovecot-cvs]
dovecot/src/lib-storage/index index-status.c,1.24,1.25
cras at procontrol.fi
cras at procontrol.fi
Fri May 30 05:53:09 EEST 2003
Update of /home/cvs/dovecot/src/lib-storage/index
In directory danu:/tmp/cvs-serv15306
Modified Files:
index-status.c
Log Message:
If we're asking only custom flags (eg. APPEND), don't do any mailbox syncing.
Index: index-status.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-status.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- index-status.c 8 May 2003 02:09:45 -0000 1.24
+++ index-status.c 30 May 2003 01:53:07 -0000 1.25
@@ -5,6 +5,10 @@
#include "mail-index-util.h"
#include "index-storage.h"
+#define STATUS_MESSAGE_COUNTS \
+ (STATUS_MESSAGES | STATUS_RECENT | STATUS_UIDNEXT | \
+ STATUS_UIDVALIDITY | STATUS_UNSEEN | STATUS_FIRST_UNSEEN_SEQ)
+
static unsigned int get_first_unseen_seq(struct mail_index *index)
{
struct mail_index_header *hdr;
@@ -82,22 +86,29 @@
memset(status, 0, sizeof(struct mailbox_status));
- /* if we're doing STATUS for selected mailbox, we have to sync it
- first or STATUS reply may give different data */
- if (!index_storage_sync_and_lock(ibox, TRUE, MAIL_LOCK_UNLOCK))
- return FALSE;
+ if ((items & STATUS_MESSAGE_COUNTS) != 0) {
+ /* if we're doing STATUS for selected mailbox, we have to sync
+ it first or STATUS reply may give different data */
+ if (!index_storage_sync_and_lock(ibox, TRUE, MAIL_LOCK_UNLOCK))
+ return FALSE;
- if (!index_storage_sync_modifylog(ibox, FALSE)) {
- (void)index_storage_lock(ibox, MAIL_LOCK_UNLOCK);
- return FALSE;
+ if (!index_storage_sync_modifylog(ibox, FALSE)) {
+ (void)index_storage_lock(ibox, MAIL_LOCK_UNLOCK);
+ return FALSE;
+ }
+ } else {
+ if (!index_storage_lock(ibox, MAIL_LOCK_SHARED))
+ return FALSE;
}
/* we can get most of the status items without any trouble */
hdr = mail_index_get_header(ibox->index);
- status->messages = hdr->messages_count;
- status->unseen = hdr->messages_count - hdr->seen_messages_count;
- status->uidvalidity = hdr->uid_validity;
- status->uidnext = hdr->next_uid;
+ if ((items & STATUS_MESSAGE_COUNTS) != 0) {
+ status->messages = hdr->messages_count;
+ status->unseen = hdr->messages_count - hdr->seen_messages_count;
+ status->uidvalidity = hdr->uid_validity;
+ status->uidnext = hdr->next_uid;
+ }
status->diskspace_full = ibox->index->nodiskspace;
if (items & STATUS_FIRST_UNSEEN_SEQ) {
More information about the dovecot-cvs
mailing list