Changeset 5112:4411620e877b for imap

Show
Ignore:
Timestamp:
2007-04-10 16:07:53 (20 months ago)
Author:
Brendan Cully <brendan@…>
Branch:
HEAD
Message:

Do not hold hcache open while mailbox is open - it can lead to lockups

Location:
imap
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • imap/imap.c

    r5111 r5112  
    249249  int i, cacheno; 
    250250 
     251#ifdef USE_HCACHE 
     252  imap_hcache_open (idata); 
     253#endif 
     254 
    251255  for (i = 0; i < idata->ctx->msgcount; i++) 
    252256  { 
     
    277281    } 
    278282  } 
     283 
     284#if USE_HCACHE 
     285  imap_hcache_close (idata); 
     286#endif 
    279287 
    280288  /* We may be called on to expunge at any time. We can't rely on the caller 
     
    735743  ctx->v2r = safe_calloc (count, sizeof (int)); 
    736744  ctx->msgcount = 0; 
    737 #ifdef USE_HCACHE 
    738   idata->hcache = imap_hcache_open (idata, idata->ctx->path); 
    739 #endif 
     745 
    740746  if (count && (imap_read_headers (idata, 0, count-1) < 0)) 
    741747  { 
     
    11401146  } 
    11411147 
     1148#if USE_HCACHE 
     1149  imap_hcache_open (idata); 
     1150#endif 
     1151 
    11421152  /* save messages with real (non-flag) changes */ 
    11431153  for (n = 0; n < ctx->msgcount; n++) 
     
    11751185  } 
    11761186 
     1187#if USE_HCACHE 
     1188  imap_hcache_close (idata); 
     1189#endif 
     1190 
    11771191  /* sync +/- flags for the five flags mutt cares about */ 
    11781192  rc = 0; 
     
    13081322  } 
    13091323 
    1310 #ifdef USE_HCACHE 
    1311   mutt_hcache_close (idata->hcache); 
    1312   idata->hcache = NULL; 
    1313 #endif 
    13141324  mutt_bcache_close (&idata->bcache); 
    13151325 
  • imap/imap_private.h

    r5111 r5112  
    260260/* util.c */ 
    261261#ifdef USE_HCACHE 
    262 header_cache_t* imap_hcache_open (IMAP_DATA* idata, const char* path); 
     262int imap_hcache_open (IMAP_DATA* idata); 
     263void imap_hcache_close (IMAP_DATA* idata); 
    263264HEADER* imap_hcache_get (IMAP_DATA* idata, unsigned int uid); 
    264265int imap_hcache_put (IMAP_DATA* idata, HEADER* h); 
  • imap/message.c

    r5098 r5112  
    120120 
    121121#if USE_HCACHE 
     122  imap_hcache_open (idata); 
     123 
    122124  if (idata->hcache && !msgbegin) 
    123125  { 
     
    200202        if (h.data) 
    201203          imap_free_header_data ((void**) (void*) &h.data); 
     204        imap_hcache_close (idata); 
    202205        fclose (fp); 
    203206        return -1; 
     
    301304      if (h.data) 
    302305        imap_free_header_data ((void**) (void*) &h.data); 
     306#if USE_HCACHE 
     307      imap_hcache_close (idata); 
     308#endif 
    303309      fclose (fp); 
    304310      return -1; 
     
    330336    mutt_hcache_store_raw (idata->hcache, "/UIDNEXT", &idata->uidnext, 
    331337                           sizeof (idata->uidnext), imap_hcache_keylen); 
     338 
     339  imap_hcache_close (idata); 
    332340#endif /* USE_HCACHE */ 
    333341 
  • imap/util.c

    r5111 r5112  
    7272 
    7373#ifdef USE_HCACHE 
    74 header_cache_t* imap_hcache_open (IMAP_DATA* idata, const char* path) 
     74int imap_hcache_open (IMAP_DATA* idata) 
    7575{ 
    7676  IMAP_MBOX mx; 
     
    7878  char cachepath[LONG_STRING]; 
    7979 
    80   if (imap_parse_path (path, &mx) < 0) 
    81     return NULL; 
     80  if (imap_parse_path (idata->ctx->path, &mx) < 0) 
     81    return -1; 
    8282 
    8383  mutt_account_tourl (&idata->conn->account, &url); 
     
    8686  FREE (&mx.mbox); 
    8787 
    88   return mutt_hcache_open (HeaderCache, cachepath); 
     88  idata->hcache = mutt_hcache_open (HeaderCache, cachepath); 
     89 
     90  return idata->hcache != NULL ? 0 : -1; 
     91} 
     92 
     93void imap_hcache_close (IMAP_DATA* idata) 
     94{ 
     95  if (!idata->hcache) 
     96    return; 
     97 
     98  mutt_hcache_close (idata->hcache); 
     99  idata->hcache = NULL; 
    89100} 
    90101