httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Holsman <Ian.Hols...@cnet.com>
Subject RE: cvs commit: httpd-2.0/modules/experimental mod_mem_cache.c
Date Tue, 12 Feb 2002 22:17:30 GMT
diff is wonderfull.
here is the code above & below the diff

    cache_object_t *obj = h->cache_obj;

    if (sconf->lock) {
        apr_thread_mutex_lock(sconf->lock);
    }
    /* 
     * RACE .. some one might have just deleted this object .. so test
     * if it is still around
     */
    if (obj) {
        apr_hash_set(sconf->cacheht, obj->key, strlen(obj->key), NULL);
        cleanup_cache_object(obj);
        h->cache_obj = NULL;
    }
    if (sconf->lock) {
        apr_thread_mutex_unlock(sconf->lock);
    }    

> -----Original Message-----
> From: Ryan Bloom [mailto:rbb@covalent.net]
> Sent: Tuesday, February 12, 2002 2:12 PM
> To: dev@httpd.apache.org; httpd-2.0-cvs@apache.org
> Subject: RE: cvs commit: httpd-2.0/modules/experimental 
> mod_mem_cache.c
> 
> 
> 
> Doesn't the race condition still exist?   For example, I can 
> delete the
> object after the if but before the hash_set.  You need a mutex, don't
> you?
> 
> Ryan
> 
> >   -    apr_hash_set(sconf->cacheht, obj->key, 
> strlen(obj->key), NULL);
> >   +    /*
> >   +     * RACE .. some one might have just deleted this object .. so
> test
> >   +     * if it is still around
> >   +     */
> >   +    if (obj) {
> >   +        apr_hash_set(sconf->cacheht, obj->key, strlen(obj->key),
> NULL);
> >   +        cleanup_cache_object(obj);
> >   +        h->cache_obj = NULL;
> >   +    }
> >        if (sconf->lock) {
> >            apr_thread_mutex_unlock(sconf->lock);
> >   -    }
> >   -
> >   -    cleanup_cache_object(obj);
> >   +    }
> > 
> >        return OK;
> >    }
> > 
> > 
> > 
> 

Mime
View raw message