Changeset 5073:efbcef81ac49

Show
Ignore:
Timestamp:
2007-04-05 17:33:47 (22 months ago)
Author:
Brendan Cully <brendan@…>
Branch:
HEAD
Message:

Keep hcache pointer in idata, open and close with mailbox

Files:
5 modified

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r5070 r5073  
    1 2007-04-05 15:21 -0700  Brendan Cully  <brendan@kublai.com>  (7cf4415ec23d) 
     12007-04-05 17:07 -0700  Brendan Cully  <brendan@kublai.com>  (26b19fc9b78c) 
     2 
     3        * hcache.c: Do not cache some unsafe header fields. 
     4 
     5        * imap/message.c, mh.c: Small hcache-related memory leaks 
     6 
     7        * hcache.c, mh.c: Fix mh header caching (closes #2472) 
    28 
    39        * configure.ac: Teach --with-gdbm to accept a prefix (closes #2413) 
  • imap/imap.c

    r5046 r5073  
    250250 
    251251#if USE_HCACHE 
    252   header_cache_t *hc; 
    253252  char uidbuf[32]; 
    254  
    255   hc = imap_hcache_open (idata, idata->ctx->path); 
    256253#endif 
    257254 
     
    269266      imap_cache_del (idata, h); 
    270267#if USE_HCACHE 
    271       if (hc) 
     268      if (idata->hcache) 
    272269      { 
    273270        sprintf (uidbuf, "/%u", HEADER_DATA(h)->uid); 
    274         mutt_hcache_delete (hc, uidbuf, imap_hcache_keylen); 
     271        mutt_hcache_delete (idata->hcache, uidbuf, imap_hcache_keylen); 
    275272      } 
    276273#endif 
     
    288285    } 
    289286  } 
    290  
    291 #if USE_HCACHE 
    292   mutt_hcache_close (hc); 
    293 #endif 
    294287 
    295288  /* We may be called on to expunge at any time. We can't rely on the caller 
     
    750743  ctx->v2r = safe_calloc (count, sizeof (int)); 
    751744  ctx->msgcount = 0; 
     745#ifdef USE_HCACHE 
     746  idata->hcache = imap_hcache_open (idata, idata->ctx->path); 
     747#endif 
    752748  if (count && (imap_read_headers (idata, 0, count-1) < 0)) 
    753749  { 
     
    762758 
    763759 fail: 
     760#ifdef USE_HCACHE 
     761  mutt_hcache_close (idata->hcache); 
     762#endif 
    764763  if (idata->state == IMAP_SELECTED) 
    765764    idata->state = IMAP_AUTHENTICATED; 
     
    11091108  int rc; 
    11101109#if USE_HCACHE 
    1111   void* hc = NULL; 
    11121110  char uidbuf[32]; 
    11131111#endif 
     
    11561154  } 
    11571155 
    1158 #if USE_HCACHE 
    1159   if (expunge && ctx->closing) 
    1160     hc = imap_hcache_open (idata, idata->ctx->path); 
    1161 #endif 
    1162  
    11631156  /* save messages with real (non-flag) changes */ 
    11641157  for (n = 0; n < ctx->msgcount; n++) 
     
    11691162      imap_cache_del (idata, h); 
    11701163#if USE_HCACHE 
    1171     if (hc && h->deleted) 
     1164    if (idata->hcache && h->deleted) 
    11721165    { 
    11731166      sprintf (uidbuf, "/%u", HEADER_DATA(h)->uid); 
    1174       mutt_hcache_delete (hc, uidbuf, imap_hcache_keylen); 
     1167      mutt_hcache_delete (idata->hcache, uidbuf, imap_hcache_keylen); 
    11751168    } 
    11761169#endif 
     
    12721265  rc = 0; 
    12731266 out: 
    1274 #if USE_HCACHE 
    1275   mutt_hcache_close (hc); 
    1276 #endif 
    12771267  if (cmd.data) 
    12781268    FREE (&cmd.data); 
     
    13331323  } 
    13341324 
     1325#ifdef USE_HCACHE 
     1326  mutt_hcache_close (idata->hcache); 
     1327#endif 
    13351328  mutt_bcache_close (&idata->bcache); 
    13361329 
  • imap/imap_private.h

    r5064 r5073  
    2525#include "mutt_socket.h" 
    2626#include "bcache.h" 
     27#ifdef USE_HCACHE 
     28#include "hcache.h" 
     29#endif 
    2730 
    2831/* -- symbols -- */ 
     
    209212  /* all folder flags - system flags AND keywords */ 
    210213  LIST *flags; 
     214#ifdef USE_HCACHE 
     215  header_cache_t *hcache; 
     216#endif 
    211217} IMAP_DATA; 
    212218/* I wish that were called IMAP_CONTEXT :( */ 
     
    254260/* util.c */ 
    255261#ifdef USE_HCACHE 
    256 void* imap_hcache_open (IMAP_DATA* idata, const char* path); 
     262header_cache_t* imap_hcache_open (IMAP_DATA* idata, const char* path); 
    257263#endif 
    258264 
  • imap/message.c

    r5071 r5073  
    7676 
    7777#if USE_HCACHE 
    78   header_cache_t *hc = NULL; 
    7978  unsigned int *uid_validity = NULL; 
    8079  unsigned int *uidnext = NULL; 
     
    122121 
    123122#if USE_HCACHE 
    124   if (!msgbegin) 
    125     hc = imap_hcache_open (idata, ctx->path); 
    126  
    127   if (hc) 
    128   { 
    129     uid_validity = mutt_hcache_fetch_raw (hc, "/UIDVALIDITY", imap_hcache_keylen); 
    130     uidnext = mutt_hcache_fetch_raw (hc, "/UIDNEXT", imap_hcache_keylen); 
     123  if (idata->hcache) 
     124  { 
     125    uid_validity = mutt_hcache_fetch_raw (idata->hcache, "/UIDVALIDITY", imap_hcache_keylen); 
     126    uidnext = mutt_hcache_fetch_raw (idata->hcache, "/UIDNEXT", imap_hcache_keylen); 
    131127    if (uid_validity && uidnext && *uid_validity == idata->uid_validity 
    132128        && *uidnext > 0) 
     
    174170        idx = h.sid - 1; 
    175171        sprintf(uid_buf, "/%u", h.data->uid); /* XXX --tg 21:41 04-07-11 */ 
    176         uid_validity = (unsigned int*)mutt_hcache_fetch (hc, uid_buf, &imap_hcache_keylen); 
     172        uid_validity = (unsigned int*)mutt_hcache_fetch (idata->hcache, uid_buf, &imap_hcache_keylen); 
    177173 
    178174        if (uid_validity != NULL && *uid_validity == idata->uid_validity) 
     
    210206          imap_free_header_data ((void**) &h.data); 
    211207        fclose (fp); 
    212         mutt_hcache_close (hc); 
    213208        return -1; 
    214209      } 
     
    300295#if USE_HCACHE 
    301296      sprintf(uid_buf, "/%u", h.data->uid); 
    302       mutt_hcache_store(hc, uid_buf, ctx->hdrs[idx], idata->uid_validity, &imap_hcache_keylen); 
     297      mutt_hcache_store(idata->hcache, uid_buf, ctx->hdrs[idx], idata->uid_validity, &imap_hcache_keylen); 
    303298#endif /* USE_HCACHE */ 
    304299 
     
    313308        imap_free_header_data ((void**) &h.data); 
    314309      fclose (fp); 
    315 #if USE_HCACHE 
    316       mutt_hcache_close (hc); 
    317 #endif /* USE_HCACHE */ 
    318310      return -1; 
    319311    } 
     
    334326 
    335327#if USE_HCACHE 
    336   mutt_hcache_store_raw (hc, "/UIDVALIDITY", &idata->uid_validity, 
     328  mutt_hcache_store_raw (idata->hcache, "/UIDVALIDITY", &idata->uid_validity, 
    337329                         sizeof (idata->uid_validity), imap_hcache_keylen); 
    338330  if (maxuid && idata->uidnext < maxuid + 1) 
     
    342334  } 
    343335  if (idata->uidnext > 1) 
    344     mutt_hcache_store_raw (hc, "/UIDNEXT", &idata->uidnext, 
     336    mutt_hcache_store_raw (idata->hcache, "/UIDNEXT", &idata->uidnext, 
    345337                           sizeof (idata->uidnext), imap_hcache_keylen); 
    346   mutt_hcache_close (hc); 
    347338#endif /* USE_HCACHE */ 
    348339 
  • imap/util.c

    r5055 r5073  
    7171 
    7272#ifdef USE_HCACHE 
    73 void* imap_hcache_open (IMAP_DATA* idata, const char* path) 
     73header_cache_t* imap_hcache_open (IMAP_DATA* idata, const char* path) 
    7474{ 
    7575  IMAP_MBOX mx;