X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/0e5441d8161042493fcfdacaeed2a770f1f7285c..f99e660b44281cd6bd6c24c60f1ebfb5e0e994e1:/src/object.c diff --git a/src/object.c b/src/object.c index 25567e2a..51582619 100644 --- a/src/object.c +++ b/src/object.c @@ -35,7 +35,8 @@ robj *createStringObject(char *ptr, size_t len) { robj *createStringObjectFromLongLong(long long value) { robj *o; - if (value >= 0 && value < REDIS_SHARED_INTEGERS) { + if (value >= 0 && value < REDIS_SHARED_INTEGERS && + pthread_equal(pthread_self(),server.mainthread)) { incrRefCount(shared.integers[value]); o = shared.integers[value]; } else { @@ -178,6 +179,7 @@ void decrRefCount(void *obj) { case REDIS_HASH: freeHashObject(o); break; default: redisPanic("Unknown object type"); break; } + o->ptr = NULL; /* defensive programming. We'll see NULL in traces. */ if (server.vm_enabled) pthread_mutex_lock(&server.obj_freelist_mutex); if (listLength(server.objfreelist) > REDIS_OBJFREELIST_MAX || !listAddNodeHead(server.objfreelist,o)) @@ -216,7 +218,7 @@ robj *tryObjectEncoding(robj *o) { /* Ok, this object can be encoded... * * Can I use a shared object? Only if the object is inside a given - * range and if this is the main thread, sinc when VM is enabled we + * range and if this is the main thread, since when VM is enabled we * have the constraint that I/O thread should only handle non-shared * objects, in order to avoid race conditions (we don't have per-object * locking). */