Index: append.c =================================================================== RCS file: /afs/andrew/system/cvs/src/cyrus/imap/append.c,v retrieving revision 1.111 diff -u -r1.111 append.c --- append.c 5 Sep 2007 17:26:26 -0000 1.111 +++ append.c 13 Sep 2007 14:55:53 -0000 @@ -576,7 +576,8 @@ /* ok, we've successfully created the file */ if (!*body || (as->nummsg - 1)) r = message_parse_file(destfile, NULL, NULL, body); - if (!r) r = message_create_record(mailbox, &message_index, *body); + if (!r) r = message_create_record(mailbox->name, mailbox->cache_fd, + &message_index, *body); } if (destfile) { /* this will hopefully ensure that the link() actually happened @@ -741,7 +742,8 @@ if (!r) { if (!*body || (as->nummsg - 1)) r = message_parse_file(destfile, NULL, NULL, body); - if (!r) r = message_create_record(mailbox, &message_index, *body); + if (!r) r = message_create_record(mailbox->name, mailbox->cache_fd, + &message_index, *body); } fclose(destfile); if (r) { @@ -950,7 +952,8 @@ &src_base, &src_size); if (!r) r = message_parse_file(destfile, NULL, NULL, &body); - if (!r) r = message_create_record(append_mailbox, + if (!r) r = message_create_record(append_mailbox->name, + append_mailbox->cache_fd, &message_index[msg], body); if (body) message_free_body(body); fclose(destfile); Index: message.c =================================================================== RCS file: /afs/andrew/system/cvs/src/cyrus/imap/message.c,v retrieving revision 1.106 diff -u -r1.106 message.c --- message.c 12 Sep 2007 17:53:29 -0000 1.106 +++ message.c 13 Sep 2007 14:55:53 -0000 @@ -328,12 +328,10 @@ } /* - * Parse the message 'infile' in 'mailbox'. Appends the message's - * cache information to the mailbox's cache file and fills in - * appropriate information in the index record pointed to by - * 'message_index'. + * Parse the message 'infile'. * * The caller MUST free the allocated body struct. + * * If msg_base/msg_len are non-NULL, the file will remain memory-mapped * and returned to the caller. The caller MUST unmap the file. */ @@ -372,10 +370,7 @@ /* - * Parse the message 'infile' in 'mailbox'. Appends the message's - * cache information to the mailbox's cache file and fills in - * appropriate information in the index record pointed to by - * 'message_index'. + * Parse the message 'infile'. * * The caller MUST free the allocated body struct. * @@ -429,10 +424,7 @@ /* - * Parse the message at 'msg_base' of length 'msg_len' in 'mailbox'. - * Appends the message's cache information to the mailbox's cache file - * and fills in appropriate information in the index record pointed to - * by 'message_index'. + * Parse the message at 'msg_base' of length 'msg_len'. */ int message_parse_mapped(const char *msg_base, unsigned long msg_len, struct body *body) @@ -521,13 +513,14 @@ } /* - * Appends the message's cache information to the mailbox's cache file + * Appends the message's cache information to the cache file * and fills in appropriate information in the index record pointed to * by 'message_index'. */ int -message_create_record(mailbox, message_index, body) -struct mailbox *mailbox; +message_create_record(cache_name, cache_fd, message_index, body) +const char *cache_name; +int cache_fd; struct index_record *message_index; struct body *body; { @@ -539,59 +532,14 @@ message_index->content_offset = body->content_offset; message_index->content_lines = body->content_lines; - message_index->cache_offset = lseek(mailbox->cache_fd, 0, SEEK_CUR); + message_index->cache_offset = lseek(cache_fd, 0, SEEK_CUR); message_index->cache_version = MAILBOX_CACHE_MINOR_VERSION; - n = message_write_cache(mailbox->cache_fd, body); - - if (n == -1) { - syslog(LOG_ERR, "IOERROR: appending cache for %s: %m", mailbox->name); - return IMAP_IOERROR; - } - - return 0; -} - -/* YYY Following used by sync_support.c. Should use message_create_record() - * instead now that is available? - * - * Parse the message at 'msg_base' of length 'msg_len' in 'mailbox'. - * Appends the message's cache information to the mailbox's cache file - * and fills in appropriate information in the index record pointed to - * by 'message_index'. - */ -int -message_parse_mapped_async(msg_base, msg_len, format, cache_fd, message_index) -const char *msg_base; -unsigned long msg_len; -int format; -int cache_fd; -struct index_record *message_index; -{ - struct body body; - struct msg msg; - int n; - - msg.base = msg_base; - msg.len = msg_len; - msg.offset = 0; - msg.encode = 0; - - message_parse_body(&msg, format, &body, - DEFAULT_CONTENT_TYPE, (struct boundary *)0); - - message_index->sentdate = message_parse_date(body.date, 0); - message_index->size = body.header_size + body.content_size; - message_index->header_size = body.header_size; - message_index->content_offset = body.content_offset; - - message_index->cache_offset = lseek(cache_fd, 0, SEEK_CUR); - n = message_write_cache(cache_fd, &body); - message_free_body(&body); + n = message_write_cache(cache_fd, body); if (n == -1) { - syslog(LOG_ERR, "IOERROR: appending cache for sync_server: %m"); + syslog(LOG_ERR, "IOERROR: appending cache for %s: %m", cache_name); return IMAP_IOERROR; } Index: message.h =================================================================== RCS file: /afs/andrew/system/cvs/src/cyrus/imap/message.h,v retrieving revision 1.8 diff -u -r1.8 message.h --- message.h 19 Dec 2006 18:56:27 -0000 1.8 +++ message.h 13 Sep 2007 14:55:53 -0000 @@ -92,14 +92,10 @@ extern void message_fetch_part P((struct message_content *msg, const char **content_types, struct bodypart ***parts)); -extern int message_create_record P((struct mailbox *mailbox, +extern int message_create_record P((const char *cache_name, + int cache_fd, struct index_record *message_index, struct body *body)); extern void message_free_body P((struct body *body)); - -extern int -message_parse_mapped_async P((const char *msg_base, unsigned long msg_len, - int format, int cache_fd, - struct index_record *message_index)); #endif /* INCLUDED_MESSAGE_H */ Index: reconstruct.c =================================================================== RCS file: /afs/andrew/system/cvs/src/cyrus/imap/reconstruct.c,v retrieving revision 1.94 diff -u -r1.94 reconstruct.c --- reconstruct.c 12 Sep 2007 14:55:19 -0000 1.94 +++ reconstruct.c 13 Sep 2007 14:55:54 -0000 @@ -1008,7 +1008,8 @@ if (uuid_set) message_uuid_set_null(&message_index.uuid); if (((r = message_parse_file(msgfile, NULL, NULL, &body)) != 0) || - ((r = message_create_record(&mailbox, &message_index, body)) != 0)) { + ((r = message_create_record(mailbox.name, mailbox.cache_fd, + &message_index, body)) != 0)) { fclose(msgfile); fclose(newindex); mailbox_close(&mailbox); Index: sync_support.c =================================================================== RCS file: /afs/andrew/system/cvs/src/cyrus/imap/sync_support.c,v retrieving revision 1.11 diff -u -r1.11 sync_support.c --- sync_support.c 12 Sep 2007 15:51:04 -0000 1.11 +++ sync_support.c 13 Sep 2007 14:55:54 -0000 @@ -1288,8 +1288,7 @@ FILE *file; int r = 0; unsigned long size; - const char *msg_base = 0; - unsigned long msg_len = 0; + struct body *body = NULL; struct index_record record; char buf[8192+1]; int n; @@ -1344,13 +1343,11 @@ return(IMAP_IOERROR); } - map_refresh(fileno(file), 1, &msg_base, &msg_len, message->msg_size, - "new message", "unknown"); - - r = message_parse_mapped_async(msg_base, msg_len, - MAILBOX_FORMAT_NORMAL, - list->cache_fd, &record); - map_free(&msg_base, &msg_len); + r = message_parse_file(file, NULL, NULL, &body); + if (!r) r = message_create_record(list->cache_name, + list->cache_fd, + &record, body); + if (body) message_free_body(body); message->hdr_size = record.header_size; message->cache_offset = record.cache_offset;