Fix race condition where redis context is used outside mutex protection

pull/506/head
Claudiu Boriga 8 years ago
parent 2fc2b3bab7
commit 229b78d2b8

@ -2156,14 +2156,13 @@ void redis_update_onekey(struct call *c, struct redis *r) {
return; return;
err: err:
mutex_unlock(&r->lock);
rwlock_unlock_r(&c->master_lock);
if (r->ctx && r->ctx->err) if (r->ctx && r->ctx->err)
rlog(LOG_ERR, "Redis error: %s", r->ctx->errstr); rlog(LOG_ERR, "Redis error: %s", r->ctx->errstr);
redisFree(r->ctx); redisFree(r->ctx);
r->ctx = NULL; r->ctx = NULL;
mutex_unlock(&r->lock);
rwlock_unlock_r(&c->master_lock);
} }
/* must be called lock-free */ /* must be called lock-free */
@ -2189,13 +2188,13 @@ void redis_delete(struct call *c, struct redis *r) {
return; return;
err: err:
rwlock_unlock_r(&c->master_lock);
mutex_unlock(&r->lock);
if (r->ctx && r->ctx->err) if (r->ctx && r->ctx->err)
rlog(LOG_ERR, "Redis error: %s", r->ctx->errstr); rlog(LOG_ERR, "Redis error: %s", r->ctx->errstr);
redisFree(r->ctx); redisFree(r->ctx);
r->ctx = NULL; r->ctx = NULL;
rwlock_unlock_r(&c->master_lock);
mutex_unlock(&r->lock);
} }

Loading…
Cancel
Save