Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
44262c58
Commit
44262c58
authored
Jun 03, 2010
by
antirez
Browse files
Fixed VM bugs introduced with the top level keys as sds strings changes
parent
09241813
Changes
1
Show whitespace changes
Inline
Side-by-side
redis.c
View file @
44262c58
...
@@ -9358,7 +9358,8 @@ static int vmSwapOneObject(int usethreads) {
...
@@ -9358,7 +9358,8 @@ static int vmSwapOneObject(int usethreads) {
struct dictEntry *best = NULL;
struct dictEntry *best = NULL;
double best_swappability = 0;
double best_swappability = 0;
redisDb *best_db = NULL;
redisDb *best_db = NULL;
robj
*
key
,
*
val
;
robj *val;
sds key;
for (j = 0; j < server.dbnum; j++) {
for (j = 0; j < server.dbnum; j++) {
redisDb *db = server.db+j;
redisDb *db = server.db+j;
...
@@ -9374,7 +9375,6 @@ static int vmSwapOneObject(int usethreads) {
...
@@ -9374,7 +9375,6 @@ static int vmSwapOneObject(int usethreads) {
if (maxtries) maxtries--;
if (maxtries) maxtries--;
de = dictGetRandomKey(db->dict);
de = dictGetRandomKey(db->dict);
key
=
dictGetEntryKey
(
de
);
val = dictGetEntryVal(de);
val = dictGetEntryVal(de);
/* Only swap objects that are currently in memory.
/* Only swap objects that are currently in memory.
*
*
...
@@ -9399,11 +9399,11 @@ static int vmSwapOneObject(int usethreads) {
...
@@ -9399,11 +9399,11 @@ static int vmSwapOneObject(int usethreads) {
val = dictGetEntryVal(best);
val = dictGetEntryVal(best);
redisLog(REDIS_DEBUG,"Key with best swappability: %s, %f",
redisLog(REDIS_DEBUG,"Key with best swappability: %s, %f",
key
->
ptr
,
best_swappability
);
key, best_swappability);
/* Swap it */
/* Swap it */
if (usethreads) {
if (usethreads) {
vmSwapObjectThreaded
(
key
,
val
,
best_db
);
vmSwapObjectThreaded(
createStringObject(key,sdslen(key))
,val,best_db);
return REDIS_OK;
return REDIS_OK;
} else {
} else {
vmpointer *vp;
vmpointer *vp;
...
@@ -9489,7 +9489,7 @@ static void vmThreadedIOCompletedJob(aeEventLoop *el, int fd, void *privdata,
...
@@ -9489,7 +9489,7 @@ static void vmThreadedIOCompletedJob(aeEventLoop *el, int fd, void *privdata,
/* Post process it in the main thread, as there are things we
/* Post process it in the main thread, as there are things we
* can do just here to avoid race conditions and/or invasive locks */
* can do just here to avoid race conditions and/or invasive locks */
redisLog(REDIS_DEBUG,"COMPLETED Job type: %d, ID %p, key: %s", j->type, (void*)j->id, (unsigned char*)j->key->ptr);
redisLog(REDIS_DEBUG,"COMPLETED Job type: %d, ID %p, key: %s", j->type, (void*)j->id, (unsigned char*)j->key->ptr);
de
=
dictFind
(
j
->
db
->
dict
,
j
->
key
);
de = dictFind(j->db->dict,j->key
->ptr
);
redisAssert(de != NULL);
redisAssert(de != NULL);
if (j->type == REDIS_IOJOB_LOAD) {
if (j->type == REDIS_IOJOB_LOAD) {
redisDb *db;
redisDb *db;
...
@@ -9804,8 +9804,6 @@ static void queueIOJob(iojob *j) {
...
@@ -9804,8 +9804,6 @@ static void queueIOJob(iojob *j) {
static int vmSwapObjectThreaded(robj *key, robj *val, redisDb *db) {
static int vmSwapObjectThreaded(robj *key, robj *val, redisDb *db) {
iojob *j;
iojob *j;
assert
(
key
->
storage
==
REDIS_VM_MEMORY
);
j = zmalloc(sizeof(*j));
j = zmalloc(sizeof(*j));
j->type = REDIS_IOJOB_PREPARE_SWAP;
j->type = REDIS_IOJOB_PREPARE_SWAP;
j->db = db;
j->db = db;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment