diff options
Diffstat (limited to 'mail/mutt-devel/files/extra-patch-maildir-header-cache')
| -rw-r--r-- | mail/mutt-devel/files/extra-patch-maildir-header-cache | 419 |
1 files changed, 234 insertions, 185 deletions
diff --git a/mail/mutt-devel/files/extra-patch-maildir-header-cache b/mail/mutt-devel/files/extra-patch-maildir-header-cache index d4e6678c23cd..df28dd82a648 100644 --- a/mail/mutt-devel/files/extra-patch-maildir-header-cache +++ b/mail/mutt-devel/files/extra-patch-maildir-header-cache @@ -2,206 +2,255 @@ diff -Nru a/PATCHES b/PATCHES --- a/PATCHES +++ b/PATCHES @@ -0,0 +1 @@ -+mutt-cvs-header-cache.29 -diff -Nru a/init.h b/init.h ---- a/init.h 2005-02-12 22:08:19 +01:00 -+++ b/init.h 2005-02-13 00:51:10 +01:00 -@@ -1032,6 +1032,13 @@ - ** global header cache for all folders is used. Per default it is unset and so - ** no header caching will be used. - */ -+ { "maildir_header_cache_verify", DT_BOOL, R_NONE, OPTHCACHEVERIFY, 1 }, -+ /* -+ ** .pp -+ ** Check for Maildir unaware programs other than mutt having modified maildir -+ ** files when the header cache is in use. This incurs one stat(2) per -+ ** message every time the folder is opened. -+ */ - { "header_cache_pagesize", DT_STR, R_NONE, UL &HeaderCachePageSize, UL "16384" }, - /* - ** .pp -diff -Nru a/mh.c b/mh.c ---- a/mh.c 2005-02-03 19:01:43 +01:00 -+++ b/mh.c 2005-02-05 12:25:16 +01:00 -@@ -791,6 +791,14 @@ - return r; ++mutt-cvs-header-cache.30 +--- a/configure.in ++++ b/configure.in +@@ -804,10 +804,23 @@ + OLDLIBS="$LIBS" + + need_md5="yes" ++ ++ ac_prefer_qdbm=yes ++ AC_ARG_WITH(qdbm, AC_HELP_STRING([--without-qdbm], [Don't use qdbm even if it is available]), ++ ac_prefer_qdbm=$withval) ++ if test x$ac_prefer_qdbm != xno; then ++ CPPFLAGS="$OLDCPPFLAGS" ++ LIBS="$OLDLIBS -lqdbm"; ++ AC_CACHE_CHECK(for vlopen, ac_cv_vlopen,[ ++ ac_cv_vlopen=no ++ AC_TRY_LINK([#include <villa.h>],[vlopen(0,0,0);],[ac_cv_vlopen=yes]) ++ ]) ++ fi ++ + ac_prefer_gdbm=yes + AC_ARG_WITH(gdbm, AC_HELP_STRING([--without-gdbm], [Don't use gdbm even if it is available]), + ac_prefer_gdbm=$withval) +- if test x$ac_prefer_gdbm != xno; then ++ if test x$ac_prefer_gdbm != xno -a x$ac_cv_vlopen != xyes; then + CPPFLAGS="$OLDCPPFLAGS" + LIBS="$OLDLIBS -lgdbm"; + AC_CACHE_CHECK(for gdbm_open, ac_cv_gdbmopen,[ +@@ -819,7 +832,7 @@ + ac_bdb_prefix=yes + AC_ARG_WITH(bdb, AC_HELP_STRING([--with-bdb[=DIR]], [Use BerkeleyDB4 if gdbm is not available]), + ac_bdb_prefix=$withval) +- if test x$ac_bdb_prefix != xno -a x$ac_cv_gdbmopen != xyes; then ++ if test x$ac_bdb_prefix != xno -a x$ac_cv_gdbmopen != xyes -a x$ac_cv_vlopen != xyes; then + test x$ac_bdb_prefix = xyes && ac_bdb_prefix="$mutt_cv_prefix /opt/csw/bdb4 /opt /usr/local /usr" + for d in $ac_bdb_prefix; do + bdbpfx="$bdbpfx $d" +@@ -865,7 +878,11 @@ + fi + fi + +- if test x$ac_cv_gdbmopen = xyes; then ++ if test x$ac_cv_vlopen = xyes; then ++ CPPFLAGS="$OLDCPPFLAGS" ++ LIBS="$OLDLIBS -lqdbm"; ++ AC_DEFINE(HAVE_QDBM, 1, [QDBM Support]) ++ elif test x$ac_cv_gdbmopen = xyes; then + CPPFLAGS="$OLDCPPFLAGS" + LIBS="$OLDLIBS -lgdbm"; + AC_DEFINE(HAVE_GDBM, 1, [GDBM Support]) +--- a/hcache.c ++++ b/hcache.c +@@ -22,7 +22,11 @@ + #include "config.h" + #endif /* HAVE_CONFIG_H */ + +-#if HAVE_GDBM ++#if HAVE_QDBM ++#include <depot.h> ++#include <cabin.h> ++#include <villa.h> ++#elif HAVE_GDBM + #include <gdbm.h> + #elif HAVE_DB4 + #include <db.h> +@@ -42,7 +46,14 @@ + #include "lib.h" + #include "md5.h" + +-#if HAVE_GDBM ++#if HAVE_QDBM ++static struct header_cache ++{ ++ VILLA *db; ++ char *folder; ++ unsigned int crc; ++} HEADER_CACHE; ++#elif HAVE_GDBM + static struct header_cache + { + GDBM_FILE db; +@@ -615,7 +626,139 @@ + return h; } -+#if USE_HCACHE -+static size_t maildir_hcache_keylen (const char *fn) +-#if HAVE_GDBM ++#if HAVE_QDBM ++void * ++mutt_hcache_open(const char *path, const char *folder) +{ -+ const char * p = strrchr (fn, ':'); -+ return p ? (size_t) (p - fn) : mutt_strlen(fn); -+} ++ struct header_cache *h = safe_calloc(1, sizeof (HEADER_CACHE)); ++ int flags = 0; ++#if 0 /* FIXME */ ++ int pagesize = atoi(HeaderCachePageSize) ? atoi(HeaderCachePageSize) : 16384; +#endif ++ h->db = NULL; ++ h->folder = safe_strdup(folder); ++ h->crc = generate_crc32(); + - #ifdef USE_INODESORT - /* - * Merge two maildir lists according to the inode numbers. -@@ -886,27 +894,67 @@ - * This function does the second parsing pass for a maildir-style - * folder. - */ -- - void maildir_delayed_parsing (CONTEXT * ctx, struct maildir *md) - { - struct maildir *p; - char fn[_POSIX_PATH_MAX]; - int count; - -+#if USE_HCACHE -+ void *hc = NULL; -+ void *data; -+ struct timeval *when = NULL; -+ struct stat lastchanged; -+ int ret; ++ if (!path || path[0] == '\0') ++ { ++ FREE(&h->folder); ++ FREE(&h); ++ return NULL; ++ } + -+ hc = mutt_hcache_open (HeaderCache, ctx->path); -+#endif ++ path = mutt_hcache_per_folder(path, folder); ++ ++ if (option(OPTHCACHECOMPRESS)) ++ flags = VL_OZCOMP; + - for (p = md, count = 0; p; p = p->next, count++) -- if (p && p->h && !p->header_parsed) -- { -- if (!ctx->quiet && ReadInc && ((count % ReadInc) == 0 || count == 1)) -- mutt_message (_("Reading %s... %d"), ctx->path, count); -- snprintf (fn, sizeof (fn), "%s/%s", ctx->path, p->h->path); -- if (maildir_parse_message (ctx->magic, fn, p->h->old, p->h)) -- p->header_parsed = 1; -- else -- mutt_free_header (&p->h); -- } --} ++ h->db = vlopen(path, flags | VL_OWRITER | VL_OCREAT, VL_CMPLEX); ++ if (h->db) ++ return h; ++ ++ /* if rw failed try ro */ ++ h->db = vlopen(path, flags | VL_OREADER, 0); ++ if (h->db) ++ return h; ++ else + { -+ if (! (p && p->h && !p->header_parsed)) -+ continue; - -+ if (!ctx->quiet && ReadInc && ((count % ReadInc) == 0 || count == 1)) -+ mutt_message (_("Reading %s... %d"), ctx->path, count); - -+#if USE_HCACHE -+ data = mutt_hcache_fetch (hc, p->h->path + 3, &maildir_hcache_keylen); -+ when = (struct timeval *) data; -+#endif ++ FREE(&h->folder); ++ FREE(&h); ++ ++ return NULL; ++ } ++} ++ ++void ++mutt_hcache_close(void *db) ++{ ++ struct header_cache *h = db; ++ ++ if (!h) ++ return; ++ ++ vlclose(h->db); ++ FREE(&h->folder); ++ FREE(&h); ++} ++ ++void * ++mutt_hcache_fetch(void *db, const char *filename, ++ size_t(*keylen) (const char *fn)) ++{ ++ struct header_cache *h = db; ++ char path[_POSIX_PATH_MAX]; ++ int ksize; ++ char *data = NULL; ++ ++ if (!h) ++ return NULL; ++ ++ strncpy(path, h->folder, sizeof (path)); ++ safe_strcat(path, sizeof (path), filename); ++ ++ ksize = strlen(h->folder) + keylen(path + strlen(h->folder)); + -+ snprintf (fn, sizeof (fn), "%s/%s", ctx->path, p->h->path); ++ data = vlget(h->db, path, ksize, NULL); + -+#if USE_HCACHE -+ if (option(OPTHCACHEVERIFY)) -+ ret = stat(fn, &lastchanged); -+ else { -+ lastchanged.st_mtime = 0; -+ ret = 0; ++ if (! crc32_matches(data, h->crc)) ++ { ++ if (data) { ++ FREE(&data); + } -+ -+ if (data != NULL && !ret && lastchanged.st_mtime <= when->tv_sec) -+ { -+ p->h = mutt_hcache_restore ((unsigned char *)data, &p->h); -+ maildir_parse_flags (p->h, fn); -+ } else -+#endif -+ if (maildir_parse_message (ctx->magic, fn, p->h->old, p->h)) -+ { -+ p->header_parsed = 1; -+#if USE_HCACHE -+ mutt_hcache_store (hc, p->h->path + 3, p->h, 0, &maildir_hcache_keylen); -+#endif -+ } else -+ mutt_free_header (&p->h); -+#if USE_HCACHE -+ FREE(&data); -+#endif ++ return NULL; + } -+#if USE_HCACHE -+ mutt_hcache_close (hc); -+#endif ++ ++ return data; +} - - /* Read a MH/maildir style mailbox. - * -@@ -1403,6 +1451,9 @@ - { - char path[_POSIX_PATH_MAX], tmp[_POSIX_PATH_MAX]; - int i, j; -+#if USE_HCACHE -+ void *hc = NULL; -+#endif /* USE_HCACHE */ - - if (ctx->magic == M_MH) - i = mh_check_mailbox (ctx, index_hint); -@@ -1412,6 +1463,11 @@ - if (i != 0) - return i; - -+#if USE_HCACHE -+ if (ctx->magic == M_MAILDIR) -+ hc = mutt_hcache_open(HeaderCache, ctx->path); -+#endif /* USE_HCACHE */ -+ - for (i = 0; i < ctx->msgcount; i++) - { - if (ctx->hdrs[i]->deleted -@@ -1420,7 +1476,13 @@ - snprintf (path, sizeof (path), "%s/%s", ctx->path, ctx->hdrs[i]->path); - if (ctx->magic == M_MAILDIR - || (option (OPTMHPURGE) && ctx->magic == M_MH)) -+ { -+#if USE_HCACHE -+ if (ctx->magic == M_MAILDIR) -+ mutt_hcache_delete (hc, ctx->hdrs[i]->path + 3, &maildir_hcache_keylen); -+#endif /* USE_HCACHE */ - unlink (path); -+ } - else if (ctx->magic == M_MH) - { - /* MH just moves files out of the way when you delete them */ -@@ -1442,16 +1504,21 @@ - if (ctx->magic == M_MAILDIR) - { - if (maildir_sync_message (ctx, i) == -1) -- return -1; -+ goto err; - } - else - { - if (mh_sync_message (ctx, i) == -1) -- return -1; -+ goto err; - } - } - } - -+#if USE_HCACHE -+ if (ctx->magic == M_MAILDIR) -+ mutt_hcache_close (hc); -+#endif /* USE_HCACHE */ + - if (ctx->magic == M_MH) - mh_update_sequences (ctx); - -@@ -1472,6 +1539,13 @@ - } - - return 0; -+ -+err: -+#if USE_HCACHE -+ if (ctx->magic == M_MAILDIR) -+ mutt_hcache_close (hc); -+#endif /* USE_HCACHE */ -+ return -1; - } ++int ++mutt_hcache_store(void *db, const char *filename, HEADER * header, ++ unsigned long uid_validity, ++ size_t(*keylen) (const char *fn)) ++{ ++ struct header_cache *h = db; ++ char path[_POSIX_PATH_MAX]; ++ int ret; ++ int ksize, dsize; ++ char *data = NULL; ++ ++ if (!h) ++ return -1; ++ ++ strncpy(path, h->folder, sizeof (path)); ++ safe_strcat(path, sizeof (path), filename); ++ ++ ksize = strlen(h->folder) + keylen(path + strlen(h->folder)); ++ ++ data = mutt_hcache_dump(db, header, &dsize, uid_validity); ++ ++ ret = vlput(h->db, path, ksize, data, dsize, VL_DOVER); ++ ++ FREE(&data); ++ ++ return ret; ++} ++ ++int ++mutt_hcache_delete(void *db, const char *filename, ++ size_t(*keylen) (const char *fn)) ++{ ++ struct header_cache *h = db; ++ char path[_POSIX_PATH_MAX]; ++ int ksize; ++ ++ if (!h) ++ return -1; ++ ++ strncpy(path, h->folder, sizeof (path)); ++ safe_strcat(path, sizeof (path), filename); ++ ++ ksize = strlen(h->folder) + keylen(path + strlen(h->folder)); ++ ++ return vlout(h->db, path, ksize); ++} ++ ++#elif HAVE_GDBM - static char *maildir_canon_filename (char *dest, const char *src, size_t l) -diff -Nru a/mutt.h b/mutt.h ---- a/mutt.h 2005-02-12 21:19:25 +01:00 -+++ b/mutt.h 2005-02-13 00:51:10 +01:00 -@@ -351,6 +351,9 @@ - OPTFORCENAME, - OPTFORWDECODE, + void * + mutt_hcache_open(const char *path, const char *folder) +--- a/init.h ++++ b/init.h +@@ -1079,6 +1079,15 @@ + ** files when the header cache is in use. This incurs one stat(2) per + ** message every time the folder is opened. + */ ++#if HAVE_QDBM ++ { "header_cache_compress", DT_BOOL, R_NONE, OPTHCACHECOMPRESS, 0 }, ++ /* ++ ** .pp ++ ** If enabled the header cache will be compressed. So only one fifth of the usual ++ ** diskspace is used, but the uncompression can result in a slower open of the ++ ** cached folder. ++ */ ++#endif /* HAVE_QDBM */ + { "header_cache_pagesize", DT_STR, R_NONE, UL &HeaderCachePageSize, UL "16384" }, + /* + ** .pp +--- a/mutt.h ++++ b/mutt.h +@@ -353,6 +353,9 @@ OPTFORWQUOTE, -+#if USE_HCACHE -+ OPTHCACHEVERIFY, -+#endif + #if USE_HCACHE + OPTHCACHEVERIFY, ++#if HAVE_QDBM ++ OPTHCACHECOMPRESS, ++#endif /* HAVE_QDBM */ + #endif OPTHDRS, OPTHEADER, - OPTHELP, |
