Changeset 137 for trunk


Ignore:
Timestamp:
2006-09-06T08:41:04+02:00 (9 years ago)
Author:
moo
Message:

changed the coding way of unlinking list. fixed ttl expires dead loop

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xcache.c

    r136 r137  
    149149}
    150150/* }}} */
    151 static void xc_entry_free_dmz(volatile xc_entry_t *xce) /* {{{ */
     151static void xc_entry_free_real_dmz(volatile xc_entry_t *xce) /* {{{ */
    152152{
    153153    xc_mem_free(xce->cache->mem, (xc_entry_t *)xce);
     
    180180}
    181181/* }}} */
    182 static void xc_entry_remove_real_dmz(xc_entry_t *xce, xc_entry_t **pp TSRMLS_DC) /* {{{ */
    183 {
    184     *pp = xce->next;
     182static void xc_entry_free_dmz(xc_entry_t *xce TSRMLS_DC) /* {{{ */
     183{
    185184    xce->cache->entries_count --;
    186185    if (xce->refcount == 0) {
    187         xc_entry_free_dmz(xce);
     186        xc_entry_free_real_dmz(xce);
    188187    }
    189188    else {
     
    202201    for (p = *pp; p; pp = &(p->next), p = p->next) {
    203202        if (xc_entry_equal_dmz(xce, p)) {
    204             xc_entry_remove_real_dmz(xce, pp TSRMLS_CC);
     203            /* unlink */
     204            *pp = p->next;
     205            xc_entry_free_dmz(xce, pp TSRMLS_CC);
    205206            return;
    206207        }
     
    249250{
    250251    xc_entry_t *p, **pp;
     252    xc_entry_t *next;
    251253    int i, c;
    252254
    253255    for (i = 0, c = cache->hentry->size; i < c; i ++) {
    254256        pp = &(cache->entries[i]);
    255         for (p = *pp; p; p = p->next) {
     257        for (p = *pp; p; p = *pp) {
    256258            if (apply_func(p TSRMLS_CC)) {
    257                 xc_entry_remove_real_dmz(p, pp TSRMLS_CC);
     259                /* unlink */
     260                *pp = p->next;
     261                xc_entry_free_dmz(p, pp TSRMLS_CC);
    258262            }
    259263            else {
     
    342346        }
    343347        if (p->refcount == 0) {
     348            /* unlink */
    344349            *pp = p->next;
    345350            cache->deletes_count --;
    346             xc_entry_free_dmz(p);
     351            xc_entry_free_real_dmz(p);
    347352        }
    348353        else {
Note: See TracChangeset for help on using the changeset viewer.