[dovecot-cvs] dovecot/src/imap mail-storage-callbacks.c,NONE,1.1 Makefile.am,1.7,1.8 client.c,1.10,1.11 cmd-select.c,1.7,1.8 mailbox-sync.c,1.1,NONE
cras at procontrol.fi
cras at procontrol.fi
Mon Nov 25 21:02:51 EET 2002
- Previous message: [dovecot-cvs] dovecot/src/lib file-lock.c,1.3,1.4 file-lock.h,1.2,1.3
- Next message: [dovecot-cvs] dovecot/src/lib-index mail-custom-flags.c,1.13,1.14 mail-index-open.c,1.18,1.19 mail-index-util.c,1.14,1.15 mail-index-util.h,1.7,1.8 mail-index.c,1.74,1.75 mail-index.h,1.54,1.55 mail-modifylog.c,1.35,1.36
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/dovecot/src/imap
In directory danu:/tmp/cvs-serv2991/src/imap
Modified Files:
Makefile.am client.c cmd-select.c
Added Files:
mail-storage-callbacks.c
Removed Files:
mailbox-sync.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".
--- NEW FILE: mail-storage-callbacks.c ---
/* Copyright (C) 2002 Timo Sirainen */
#include "common.h"
#include "obuffer.h"
#include "imap-util.h"
#include "commands-util.h"
static void alert_no_diskspace(Mailbox *mailbox __attr_unused__, void *context)
{
Client *client = context;
client_send_line(client, "* NO [ALERT] "
"Disk space is full, delete some messages.");
}
static void notify_ok(Mailbox *mailbox __attr_unused__,
const char *text, void *context)
{
Client *client = context;
client_send_line(client, t_strconcat("* OK ", text, NULL));
o_buffer_flush(client->outbuf);
}
static void notify_no(Mailbox *mailbox __attr_unused__,
const char *text, void *context)
{
Client *client = context;
client_send_line(client, t_strconcat("* NO ", text, NULL));
o_buffer_flush(client->outbuf);
}
static void expunge(Mailbox *mailbox, unsigned int seq, void *context)
{
Client *client = context;
char str[MAX_LARGEST_T_STRLEN+20];
if (client->mailbox != mailbox)
return;
i_snprintf(str, sizeof(str), "* %u EXPUNGE", seq);
client_send_line(client, str);
}
static void update_flags(Mailbox *mailbox, unsigned int seq, unsigned int uid,
MailFlags flags, const char *custom_flags[],
unsigned int custom_flags_count, void *context)
{
Client *client = context;
const char *str;
if (client->mailbox != mailbox)
return;
t_push();
str = imap_write_flags(flags, custom_flags, custom_flags_count);
if (client->sync_flags_send_uid) {
str = t_strdup_printf("* %u FETCH (FLAGS (%s) UID %u)",
seq, str, uid);
} else {
str = t_strdup_printf("* %u FETCH (FLAGS (%s))", seq, str);
}
client_send_line(client, str);
t_pop();
}
static void new_messages(Mailbox *mailbox, unsigned int messages_count,
unsigned int recent_count, void *context)
{
Client *client = context;
char str[MAX_LARGEST_T_STRLEN+20];
if (client->mailbox != mailbox)
return;
i_snprintf(str, sizeof(str), "* %u EXISTS", messages_count);
client_send_line(client, str);
i_snprintf(str, sizeof(str), "* %u RECENT", recent_count);
client_send_line(client, str);
}
static void new_custom_flags(Mailbox *mailbox, const char *custom_flags[],
unsigned int custom_flags_count, void *context)
{
Client *client = context;
if (client->mailbox != mailbox)
return;
client_send_mailbox_flags(client, mailbox, custom_flags,
custom_flags_count);
}
MailStorageCallbacks mail_storage_callbacks = {
alert_no_diskspace,
notify_ok,
notify_no,
expunge,
update_flags,
new_messages,
new_custom_flags
};
Index: Makefile.am
===================================================================
RCS file: /home/cvs/dovecot/src/imap/Makefile.am,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- Makefile.am 25 Nov 2002 10:47:32 -0000 1.7
+++ Makefile.am 25 Nov 2002 19:02:49 -0000 1.8
@@ -53,7 +53,7 @@
client.c \
commands.c \
commands-util.c \
- mailbox-sync.c \
+ mail-storage-callbacks.c \
main.c \
rawlog.c
Index: client.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/client.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- client.c 28 Oct 2002 04:18:26 -0000 1.10
+++ client.c 25 Nov 2002 19:02:49 -0000 1.11
@@ -25,6 +25,8 @@
/* Disconnect client after idling this many seconds */
#define CLIENT_IDLE_TIMEOUT (60*30)
+extern MailStorageCallbacks mail_storage_callbacks;
+
static Client *my_client; /* we don't need more than one currently */
static Timeout to_idle;
@@ -76,6 +78,7 @@
client->last_input = ioloop_time;
client->storage = storage;
+ storage->set_callbacks(storage, &mail_storage_callbacks, client);
i_assert(my_client == NULL);
my_client = client;
Index: cmd-select.c
===================================================================
RCS file: /home/cvs/dovecot/src/imap/cmd-select.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- cmd-select.c 25 Oct 2002 01:59:36 -0000 1.7
+++ cmd-select.c 25 Nov 2002 19:02:49 -0000 1.8
@@ -4,8 +4,6 @@
#include "temp-string.h"
#include "commands.h"
-extern MailboxSyncCallbacks sync_callbacks;
-
int cmd_select_full(Client *client, int readonly)
{
Mailbox *box;
@@ -16,28 +14,29 @@
if (!client_read_string_args(client, 1, &mailbox))
return FALSE;
- if (client->mailbox != NULL)
+ if (client->mailbox != NULL) {
client->mailbox->close(client->mailbox);
+ client->mailbox = NULL;
+ }
- client->mailbox = client->storage->open_mailbox(client->storage,
- mailbox, readonly,
- FALSE);
- if (client->mailbox == NULL) {
+ box = client->storage->open_mailbox(client->storage, mailbox,
+ readonly, FALSE);
+ if (box == NULL) {
client_send_storage_error(client);
return TRUE;
}
- box = client->mailbox;
if (!box->get_status(box, STATUS_MESSAGES | STATUS_RECENT |
STATUS_FIRST_UNSEEN_SEQ | STATUS_UIDVALIDITY |
STATUS_CUSTOM_FLAGS, &status)) {
client_send_storage_error(client);
+ box->close(box);
return TRUE;
}
- /* set callbacks after STATUS, which might otherwise try calling
- some of them */
- box->set_sync_callbacks(box, &sync_callbacks, client);
+ /* set client's mailbox only after getting status to make sure
+ we're not sending any expunge/exists replies too early to client */
+ client->mailbox = box;
client_send_mailbox_flags(client, box, status.custom_flags,
status.custom_flags_count);
--- mailbox-sync.c DELETED ---
- Previous message: [dovecot-cvs] dovecot/src/lib file-lock.c,1.3,1.4 file-lock.h,1.2,1.3
- Next message: [dovecot-cvs] dovecot/src/lib-index mail-custom-flags.c,1.13,1.14 mail-index-open.c,1.18,1.19 mail-index-util.c,1.14,1.15 mail-index-util.h,1.7,1.8 mail-index.c,1.74,1.75 mail-index.h,1.54,1.55 mail-modifylog.c,1.35,1.36
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list