[dovecot-cvs] dovecot/src/lib-storage/index index-search.c,1.62,1.63 index-sort.c,1.9,1.10 index-sort.h,1.4,1.5
cras at procontrol.fi
cras at procontrol.fi
Sat Jan 11 20:55:04 EET 2003
Update of /home/cvs/dovecot/src/lib-storage/index
In directory danu:/tmp/cvs-serv14816/lib-storage/index
Modified Files:
index-search.c index-sort.c index-sort.h
Log Message:
SORT and THREAD didn't work with sequence numbers at all. SEARCH was also a
bit broken with it if another session had deleted messages which we hadn't
yet told to client.
Index: index-search.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-search.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- index-search.c 11 Jan 2003 17:48:25 -0000 1.62
+++ index-search.c 11 Jan 2003 18:55:01 -0000 1.63
@@ -824,6 +824,7 @@
struct mail_search_arg *args,
struct mail_sort_context *sort_ctx,
struct mail_thread_context *thread_ctx,
+ struct index_sort_context *index_sort_ctx,
struct ostream *output, int uid_result)
{
struct search_index_context ctx;
@@ -850,6 +851,7 @@
rec->uid, last_uid,
&expunges_before);
client_seq += expunges_before;
+ index_sort_ctx->synced_sequences = expunges->uid1 == 0;
memset(&ctx, 0, sizeof(ctx));
ctx.ibox = ibox;
@@ -860,8 +862,8 @@
while (expunges->uid1 != 0 && expunges->uid1 < rec->uid) {
i_assert(expunges->uid2 < rec->uid);
- expunges++;
client_seq += expunges->seq_count;
+ expunges++;
}
i_assert(!(expunges->uid1 <= rec->uid &&
expunges->uid2 >= rec->uid));
@@ -897,10 +899,16 @@
}
if (found) {
+ unsigned int id = uid_result ?
+ rec->uid : client_seq;
+
+ index_sort_ctx->current_client_seq = client_seq;
+ index_sort_ctx->current_rec = rec;
+
if (sort_ctx != NULL)
- mail_sort_input(sort_ctx, rec->uid);
+ mail_sort_input(sort_ctx, id);
else if (thread_ctx != NULL) {
- mail_thread_input(thread_ctx, rec->uid,
+ mail_thread_input(thread_ctx, id,
ctx.message_id,
ctx.in_reply_to,
ctx.references,
@@ -908,8 +916,7 @@
} else {
o_stream_send(output, " ", 1);
- str = dec2str(uid_result ? rec->uid :
- client_seq);
+ str = dec2str(id);
o_stream_send_str(output, str);
}
}
@@ -946,6 +953,7 @@
memset(&index_sort_ctx, 0, sizeof(index_sort_ctx));
index_sort_ctx.ibox = ibox;
index_sort_ctx.output = output;
+ index_sort_ctx.id_is_uid = uid_result;
thread_ctx = NULL;
sort_ctx = mail_sort_init(sort_unsorted, sorting, output,
@@ -955,6 +963,7 @@
} else if (threading != MAIL_THREAD_NONE) {
memset(&index_sort_ctx, 0, sizeof(index_sort_ctx));
index_sort_ctx.ibox = ibox;
+ index_sort_ctx.id_is_uid = uid_result;
sort_ctx = NULL;
thread_ctx = mail_thread_init(threading, output,
@@ -962,13 +971,14 @@
&index_sort_ctx);
o_stream_send_str(output, "* THREAD");
} else {
+ memset(&index_sort_ctx, 0, sizeof(index_sort_ctx));
sort_ctx = NULL;
thread_ctx = NULL;
o_stream_send_str(output, "* SEARCH");
}
failed = !search_messages(ibox, charset, args, sort_ctx, thread_ctx,
- output, uid_result);
+ &index_sort_ctx, output, uid_result);
if (sort_ctx != NULL)
mail_sort_deinit(sort_ctx);
if (thread_ctx != NULL)
Index: index-sort.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-sort.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- index-sort.c 11 Jan 2003 17:48:25 -0000 1.9
+++ index-sort.c 11 Jan 2003 18:55:01 -0000 1.10
@@ -6,22 +6,55 @@
#include "imap-envelope.h"
#include "imap-message-cache.h"
#include "mail-index.h"
+#include "mail-modifylog.h"
#include "index-storage.h"
#include "index-sort.h"
+static struct mail_index_record *
+lookup_client_seq(struct index_sort_context *ctx, unsigned int client_seq)
+{
+ struct mail_index_record *rec;
+ unsigned int expunges_before;
+
+ if (ctx->synced_sequences)
+ return ctx->ibox->index->lookup(ctx->ibox->index, client_seq);
+
+ t_push();
+ if (mail_modifylog_seq_get_expunges(ctx->ibox->index->modifylog,
+ client_seq, client_seq,
+ &expunges_before) == NULL) {
+ rec = NULL;
+ } else {
+ rec = ctx->ibox->index->lookup(ctx->ibox->index,
+ client_seq - expunges_before);
+ }
+ t_pop();
+
+ return rec;
+}
+
static struct imap_message_cache *
-search_open_cache(struct index_sort_context *ctx, unsigned int uid)
+search_open_cache(struct index_sort_context *ctx, unsigned int id)
{
- i_assert(uid != 0);
+ i_assert(id != 0);
- if (ctx->last_uid != uid) {
+ if (ctx->last_id != id) {
ctx->cached = FALSE;
- ctx->last_uid = uid;
+ ctx->last_id = id;
+
+ if ((ctx->id_is_uid && ctx->current_rec->uid == id) ||
+ (!ctx->id_is_uid && ctx->current_client_seq == id)) {
+ ctx->rec = ctx->current_rec;
+ } else if (ctx->id_is_uid) {
+ ctx->rec = ctx->ibox->index->
+ lookup_uid_range(ctx->ibox->index,
+ id, id, NULL);
+ } else {
+ ctx->rec = lookup_client_seq(ctx, id);
+ }
- ctx->rec = ctx->ibox->index->lookup_uid_range(ctx->ibox->index,
- uid, uid, NULL);
if (ctx->rec == NULL) {
- ctx->last_uid = 0;
+ ctx->last_id = 0;
return NULL;
}
}
Index: index-sort.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-storage/index/index-sort.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- index-sort.h 8 Jan 2003 20:49:52 -0000 1.4
+++ index-sort.h 11 Jan 2003 18:55:01 -0000 1.5
@@ -8,10 +8,15 @@
struct index_mailbox *ibox;
struct ostream *output;
- unsigned int last_uid;
+ unsigned int current_client_seq;
+ struct mail_index_record *current_rec;
+
+ unsigned int last_id;
struct mail_index_record *rec;
unsigned int cached:1;
+ unsigned int id_is_uid:1;
+ unsigned int synced_sequences:1;
};
extern struct mail_sort_callbacks index_sort_callbacks;
More information about the dovecot-cvs
mailing list