]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Added pop3_mails_keep_recent option. Fixed recent assert crash.
authorTimo Sirainen <tss@iki.fi>
Sat, 22 May 2004 22:36:46 +0000 (01:36 +0300)
committerTimo Sirainen <tss@iki.fi>
Sat, 22 May 2004 22:36:46 +0000 (01:36 +0300)
--HG--
branch : HEAD

dovecot-example.conf
src/lib-storage/index/index-storage.c
src/lib-storage/index/index-storage.h
src/lib-storage/index/maildir/maildir-sync.c
src/lib-storage/index/maildir/maildir-uidlist.c
src/lib-storage/mail-storage.h
src/master/mail-process.c
src/master/master-settings.c
src/master/master-settings.h
src/pop3/client.c

index cbfb3daff5c65a2429ce55e4b18286fbcfb93ffe..4dcd0dbd2525f16965309dd5c2d2f7f332a8680e 100644 (file)
@@ -355,6 +355,11 @@ protocol pop3 {
   # POP3 executable location
   #mail_executable = /usr/libexec/dovecot/pop3
 
+  # Don't try to set mails non-recent with POP3 sessions. This is mostly
+  # intended to reduce disk I/O. With maildir it doesn't move files from
+  # new/ to cur/, with mbox it doesn't write Status-header.
+  #pop3_mails_keep_recent = no
+
   # Support for dynamically loadable modules.
   #mail_use_modules = no
   #mail_modules = /usr/lib/dovecot/pop3
index 48fbfab7b25ac8783c0317092ed2d82bf2d6d2c3..619e6261b685ca0f443e3e2875dfeb153acf6c46 100644 (file)
@@ -330,6 +330,7 @@ index_storage_mailbox_init(struct index_storage *storage, struct mailbox *box,
                ibox->box.storage = &storage->storage;
                ibox->box.name = i_strdup(name);
                ibox->readonly = (flags & MAILBOX_OPEN_READONLY) != 0;
+               ibox->keep_recent = (flags & MAILBOX_OPEN_KEEP_RECENT) != 0;
 
                ibox->index = index;
 
index 1739c6695a570929a5ac2baa0415770e86280944..6ff80f3f0527334d465269d61d2dd4d57cc8149c 100644 (file)
@@ -99,6 +99,7 @@ struct index_mailbox {
        unsigned int private_flags_mask;
 
        unsigned int readonly:1;
+       unsigned int keep_recent:1;
        unsigned int sent_diskspace_warning:1;
        unsigned int sent_readonly_flags_warning:1;
        unsigned int autosync_pending:1;
index 54c53dba9a9a0a10aee4732b6964e19d39d1e202..bf54c1d40595780b72a88b51794191583838227e 100644 (file)
@@ -434,7 +434,8 @@ static int maildir_scan_dir(struct maildir_sync_context *ctx, int new_dir)
                return -1;
        }
 
-       move_new = new_dir && !mailbox_is_readonly(&ctx->ibox->box);
+       move_new = new_dir && !mailbox_is_readonly(&ctx->ibox->box) &&
+               !ctx->ibox->keep_recent;
        while ((dp = readdir(dirp)) != NULL) {
                if (dp->d_name[0] == '.')
                        continue;
index bfd21e6892d2693913ee3b77f58a735f911750b9..1c9fe8d0999a675245120397df189ee768e473b3 100644 (file)
@@ -145,9 +145,9 @@ void maildir_uidlist_deinit(struct maildir_uidlist *uidlist)
 static void
 maildir_uidlist_mark_recent(struct maildir_uidlist *uidlist, uint32_t uid)
 {
-       if (uidlist->first_recent_uid == 0)
+       if (uidlist->first_recent_uid == 0 ||
+           uid < uidlist->first_recent_uid)
                uidlist->first_recent_uid = uid;
-       i_assert(uid >= uidlist->first_recent_uid);
 }
 
 static int maildir_uidlist_next(struct maildir_uidlist *uidlist,
index 158af234c4f870cbfd6b89ec859bb9eb71b2e62c..15ddba35ac11054d4dc924093de501b8a8b4b829 100644 (file)
@@ -7,7 +7,8 @@ struct message_size;
 
 enum mailbox_open_flags {
        MAILBOX_OPEN_READONLY           = 0x01,
-       MAILBOX_OPEN_FAST               = 0x02
+       MAILBOX_OPEN_FAST               = 0x02,
+       MAILBOX_OPEN_KEEP_RECENT        = 0x04
 };
 
 enum mailbox_list_flags {
index ee15b971da7c454f3bce662a3112502cfc4faaec..f8af74b5b7f3be69886c15676bcb0ba8cb62277d 100644 (file)
@@ -284,6 +284,8 @@ int create_mail_process(struct login_group *group, int socket,
                env_put("MAILDIR_CHECK_CONTENT_CHANGES=1");
        if (set->mail_full_filesystem_access)
                env_put("FULL_FILESYSTEM_ACCESS=1");
+       if (set->pop3_mails_keep_recent)
+               env_put("POP3_MAILS_KEEP_RECENT=1");
        (void)umask(set->umask);
 
        env_put(t_strconcat("MBOX_LOCKS=", set->mbox_locks, NULL));
index 601ca3b2f42f5c9278350fe1311bdc45af8d362e..5a527f1ccfc361c646e7e240628355b105fe1ce3 100644 (file)
@@ -111,6 +111,9 @@ static struct setting_def setting_defs[] = {
        DEF(SET_INT, imap_max_line_length),
        DEF(SET_STR, imap_capability),
 
+       /* pop3 */
+       DEF(SET_BOOL, pop3_mails_keep_recent),
+
        { 0, NULL, 0 }
 };
 
@@ -240,6 +243,9 @@ struct settings default_settings = {
        MEMBER(imap_max_line_length) 65536,
        MEMBER(imap_capability) NULL,
 
+       /* pop3 */
+       MEMBER(pop3_mails_keep_recent) FALSE,
+
        /* .. */
        MEMBER(login_uid) 0,
        MEMBER(listen_fd) -1,
index 4cc06ae0bba93c660ee44bfbee45e11d1fcf51ff..29825a7a0e0814a65bed73c71c3ecbee04a3026c 100644 (file)
@@ -86,6 +86,9 @@ struct settings {
        unsigned int imap_max_line_length;
        const char *imap_capability;
 
+       /* pop3 */
+        int pop3_mails_keep_recent;
+
        /* .. */
        uid_t login_uid;
 
index 7a28601e82f7220820df993b2230c2a1ac0dc52b..f96785de9d5e834942c7c3468414ef92375f112a 100644 (file)
@@ -118,6 +118,7 @@ static int init_mailbox(struct client *client)
 struct client *client_create(int hin, int hout, struct mail_storage *storage)
 {
        struct client *client;
+        enum mailbox_open_flags flags;
 
        client = i_new(struct client, 1);
        client->input = i_stream_create_file(hin, default_pool,
@@ -134,7 +135,10 @@ struct client *client_create(int hin, int hout, struct mail_storage *storage)
 
        mail_storage_set_callbacks(storage, &mail_storage_callbacks, client);
 
-       client->mailbox = mailbox_open(storage, "INBOX", 0);
+       flags = 0;
+       if (getenv("POP3_MAILS_KEEP_RECENT") != NULL)
+               flags |= MAILBOX_OPEN_KEEP_RECENT;
+       client->mailbox = mailbox_open(storage, "INBOX", flags);
        if (client->mailbox == NULL) {
                client_send_line(client, "-ERR No INBOX for user.");
                client_destroy(client);