Status of multithreaded code
Ben Hartshorne
memcache at green.hartshorne.net
Sat May 26 01:13:02 UTC 2007
Too quick to hit send.
I can answer this question - though memcached.h alternately defines
item_get_nocheck as mt_item_get_nocheck or do_item_get_nocheck,
depending on whether it's running with threads, the memcached.c only
uses do_item_get_nocheck instead of the configurable item_get_nocheck.
The answer is that the multithreaded version has not yet been pulled
into the active code, though it's almost there.
-ben
On Fri, May 25, 2007 at 06:01:45PM -0700, Ben Hartshorne wrote:
> All,
>
> I saw a --enable-threads option in the configure script, along with a
> thredas.c that contained multithreaded code.
>
> What is the status of this code?
>
> I was looking at the code for mt_item_get_nocheck to get an item
> regardless of its deleted status.
>
> 392 /*
> 393 * Returns an item whether or not it's been marked as expired or deleted.
> 394 */
> 395 item *mt_item_get_nocheck(char *key, size_t nkey) {
> 396 item *it;
> 397
> 398 pthread_mutex_lock(&cache_lock);
> 399 it = assoc_find(key, nkey);
> 400 it->refcount++;
> 401 pthread_mutex_unlock(&cache_lock);
> 402 return it;
> 403 }
>
> If assoc_find returns 0 (which it does if the item is a cache miss), it
> looks to me as though the function will segfault when it tries to
> derefernce it in line 400.
>
> Thoughts?
>
> The corresponding single-threaded function checks to make sure it is
> valid before derefencing it:
>
> 402 /* returns an item whether or not it's delete-locked or expired. */
> 403 item *do_item_get_nocheck(const char *key, const size_t nkey) {
> 404 item *it = assoc_find(key, nkey);
> 405 if (it) {
> 406 it->refcount++;
> 407 DEBUG_REFCNT(it, '+');
> 408 }
> 409 return it;
> 410 }
>
> -ben
>
> --
> Ben Hartshorne
> email: ben at hartshorne.net
> http://ben.hartshorne.net
--
Ben Hartshorne
email: ben at hartshorne.net
http://ben.hartshorne.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.danga.com/pipermail/memcached/attachments/20070525/abcf6f42/attachment-0001.pgp
More information about the memcached
mailing list