Changeset 130 in svn for trunk/xcache.c


Ignore:
Timestamp:
2006-09-03T09:36:09+02:00 (9 years ago)
Author:
Xuefer
Message:

improve locking for compile

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xcache.c

    r129 r130  
    4343#define LOCK(x) xc_lock(x->lck)
    4444#define UNLOCK(x) xc_unlock(x->lck)
    45 #define ENTER_LOCK(x) do { \
    46     int catched = 0; \
     45
     46#define ENTER_LOCK_EX(x) \
    4747    xc_lock(x->lck); \
    4848    zend_try { \
    4949        do
    50 #define LEAVE_LOCK(x) \
     50#define LEAVE_LOCK_EX(x) \
    5151        while (0); \
    5252    } zend_catch { \
    5353        catched = 1; \
    5454    } zend_end_try(); \
    55     xc_unlock(x->lck); \
     55    xc_unlock(x->lck)
     56
     57#define ENTER_LOCK(x) do { \
     58    int catched = 0; \
     59    ENTER_LOCK_EX(x)
     60#define LEAVE_LOCK(x) \
     61    LEAVE_LOCK_EX(x); \
     62    if (catched) { \
     63        zend_bailout(); \
     64    } \
    5665} while(0)
     66
    5767/* }}} */
    5868
     
    763773    stored_xce = NULL;
    764774    op_array = NULL;
    765     ENTER_LOCK(cache) {
     775    ENTER_LOCK_EX(cache) {
    766776        /* clogged */
    767777        if (cache->compiling) {
     
    785795        cache->compiling = XG(request_time);
    786796        cache->misses ++;
    787     } LEAVE_LOCK(cache);
     797    } LEAVE_LOCK_EX(cache);
     798
     799    if (catched) {
     800        cache->compiling = 0;
     801        zend_bailout();
     802    }
    788803
    789804    /* found */
     
    899914    }
    900915    /* }}} */
    901     ENTER_LOCK(cache) { /* {{{ store/add entry */
     916    ENTER_LOCK_EX(cache) { /* {{{ store/add entry */
    902917        stored_xce = xc_entry_store_dmz(&xce TSRMLS_CC);
    903     } LEAVE_LOCK(cache);
     918    } LEAVE_LOCK_EX(cache);
    904919    /* }}} */
    905920#ifdef DEBUG
Note: See TracChangeset for help on using the changeset viewer.