Changeset 1366 in svn for trunk/mod_cacher/xc_cacher.c


Ignore:
Timestamp:
2013-09-09T18:16:05+02:00 (22 months ago)
Author:
Xuefer
Message:

fixes #323: refix locking impl for threaded env

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/mod_cacher/xc_cacher.c

    r1341 r1366  
    3737#define VAR_ENTRY_EXPIRED(pentry) ((pentry)->ttl && XG(request_time) > (pentry)->ctime + (time_t) (pentry)->ttl)
    3838#define CHECK(x, e) do { if ((x) == NULL) { zend_error(E_ERROR, "XCache: " e); goto err; } } while (0)
    39 #define LOCK(x) xc_lock((x)->lck)
    40 #define UNLOCK(x) xc_unlock((x)->lck)
     39#define LOCK(x) xc_mutex_lock((x)->mutex)
     40#define UNLOCK(x) xc_mutex_unlock((x)->mutex)
    4141
    4242#define ENTER_LOCK_EX(x) \
     
    101101    xc_hash_t  *hcache; /* hash to cacheid */
    102102
    103     xc_lock_t *lck;
    104     xc_shm_t  *shm; /* which shm contains us */
     103    xc_mutex_t *mutex;
     104    xc_shm_t   *shm; /* which shm contains us */
    105105    xc_allocator_t *allocator;
    106106
     
    26062606        xc_cache_t *cache = &caches[i];
    26072607        if (cache) {
    2608             if (cache->lck) {
    2609                 xc_lock_destroy(cache->lck);
    2610             }
    2611             /* do NOT touch cached data */
     2608            /* do NOT touch cached data, do not release mutex shared inside cache */
     2609            if (cache->mutex) {
     2610                xc_mutex_destroy(cache->mutex);
     2611            }
    26122612            shm = cache->shm;
    26132613            if (shm) {
     
    26562656            CHECK(cache->cached->phps = allocator->vtable->calloc(allocator, hphp->size, sizeof(xc_entry_data_php_t*)), "create phps OOM");
    26572657        }
    2658         CHECK(cache->lck              = allocator->vtable->calloc(allocator, 1, xc_lock_size()), "create lock OOM");
    2659         CHECK(xc_lock_init(cache->lck, NULL, 1), "can't create lock");
     2658        CHECK(cache->mutex            = allocator->vtable->calloc(allocator, 1, xc_mutex_size()), "create lock OOM");
     2659        CHECK(cache->mutex = xc_mutex_init(cache->mutex, NULL, 1), "can't create mutex");
    26602660
    26612661        cache->hcache  = hcache;
Note: See TracChangeset for help on using the changeset viewer.