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
f11b8647
Commit
f11b8647
authored
Jan 11, 2010
by
antirez
Browse files
a few non blocking VM bugs fixed
parent
b9bc0eef
Changes
2
Hide whitespace changes
Inline
Side-by-side
redis.c
View file @
f11b8647
...
@@ -7384,6 +7384,11 @@ static void vmThreadedIOCompletedJob(aeEventLoop *el, int fd, void *privdata,
...
@@ -7384,6 +7384,11 @@ 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
,
"Job type: %d, key at %p (%s) refcount: %d
\n
"
,
j
->
type
,
(
void
*
)
j
->
key
,
(
char
*
)
j
->
key
->
ptr
,
j
->
key
->
refcount
);
if
(
j
->
key
->
refcount
<=
0
)
{
printf
(
"Ooops ref count is <= 0!
\n
"
);
exit
(
1
);
}
de
=
dictFind
(
j
->
db
->
dict
,
j
->
key
);
de
=
dictFind
(
j
->
db
->
dict
,
j
->
key
);
assert
(
de
!=
NULL
);
assert
(
de
!=
NULL
);
key
=
dictGetEntryKey
(
de
);
key
=
dictGetEntryKey
(
de
);
...
@@ -7420,6 +7425,7 @@ static void vmThreadedIOCompletedJob(aeEventLoop *el, int fd, void *privdata,
...
@@ -7420,6 +7425,7 @@ static void vmThreadedIOCompletedJob(aeEventLoop *el, int fd, void *privdata,
key
->
storage
=
REDIS_VM_SWAPPED
;
key
->
storage
=
REDIS_VM_SWAPPED
;
key
->
vtype
=
j
->
val
->
type
;
key
->
vtype
=
j
->
val
->
type
;
decrRefCount
(
val
);
/* Deallocate the object from memory. */
decrRefCount
(
val
);
/* Deallocate the object from memory. */
dictGetEntryVal
(
de
)
=
NULL
;
vmMarkPagesUsed
(
j
->
page
,
j
->
pages
);
vmMarkPagesUsed
(
j
->
page
,
j
->
pages
);
redisLog
(
REDIS_DEBUG
,
redisLog
(
REDIS_DEBUG
,
"VM: object %s swapped out at %lld (%lld pages) (threaded)"
,
"VM: object %s swapped out at %lld (%lld pages) (threaded)"
,
...
@@ -7428,6 +7434,19 @@ static void vmThreadedIOCompletedJob(aeEventLoop *el, int fd, void *privdata,
...
@@ -7428,6 +7434,19 @@ static void vmThreadedIOCompletedJob(aeEventLoop *el, int fd, void *privdata,
server
.
vm_stats_swapped_objects
++
;
server
.
vm_stats_swapped_objects
++
;
server
.
vm_stats_swapouts
++
;
server
.
vm_stats_swapouts
++
;
freeIOJob
(
j
);
freeIOJob
(
j
);
/* Put a few more swap requests in queue if we are still
* out of memory */
if
(
zmalloc_used_memory
()
>
server
.
vm_max_memory
)
{
int
more
=
1
;
while
(
more
)
{
lockThreadedIO
();
more
=
listLength
(
server
.
io_newjobs
)
<
(
unsigned
)
server
.
vm_max_threads
;
unlockThreadedIO
();
/* Don't waste CPU time if swappable objects are rare. */
if
(
vmSwapOneObjectThreaded
()
==
REDIS_ERR
)
break
;
}
}
}
}
}
}
if
(
retval
<
0
&&
errno
!=
EAGAIN
)
{
if
(
retval
<
0
&&
errno
!=
EAGAIN
)
{
...
@@ -7572,6 +7591,7 @@ static int vmSwapObjectThreaded(robj *key, robj *val, redisDb *db) {
...
@@ -7572,6 +7591,7 @@ static int vmSwapObjectThreaded(robj *key, robj *val, redisDb *db) {
incrRefCount
(
val
);
incrRefCount
(
val
);
j
->
canceled
=
0
;
j
->
canceled
=
0
;
j
->
thread
=
(
pthread_t
)
-
1
;
j
->
thread
=
(
pthread_t
)
-
1
;
key
->
storage
=
REDIS_VM_SWAPPING
;
lockThreadedIO
();
lockThreadedIO
();
queueIOJob
(
j
);
queueIOJob
(
j
);
...
...
staticsymbols.h
View file @
f11b8647
static
struct
redisFunctionSym
symsTable
[]
=
{
static
struct
redisFunctionSym
symsTable
[]
=
{
{
"IOThreadEntryPoint"
,(
unsigned
long
)
IOThreadEntryPoint
},
{
"_redisAssert"
,(
unsigned
long
)
_redisAssert
},
{
"_redisAssert"
,(
unsigned
long
)
_redisAssert
},
{
"acceptHandler"
,(
unsigned
long
)
acceptHandler
},
{
"acceptHandler"
,(
unsigned
long
)
acceptHandler
},
{
"addReply"
,(
unsigned
long
)
addReply
},
{
"addReply"
,(
unsigned
long
)
addReply
},
...
@@ -60,6 +61,7 @@ static struct redisFunctionSym symsTable[] = {
...
@@ -60,6 +61,7 @@ static struct redisFunctionSym symsTable[] = {
{
"freeClientMultiState"
,(
unsigned
long
)
freeClientMultiState
},
{
"freeClientMultiState"
,(
unsigned
long
)
freeClientMultiState
},
{
"freeFakeClient"
,(
unsigned
long
)
freeFakeClient
},
{
"freeFakeClient"
,(
unsigned
long
)
freeFakeClient
},
{
"freeHashObject"
,(
unsigned
long
)
freeHashObject
},
{
"freeHashObject"
,(
unsigned
long
)
freeHashObject
},
{
"freeIOJob"
,(
unsigned
long
)
freeIOJob
},
{
"freeListObject"
,(
unsigned
long
)
freeListObject
},
{
"freeListObject"
,(
unsigned
long
)
freeListObject
},
{
"freeMemoryIfNeeded"
,(
unsigned
long
)
freeMemoryIfNeeded
},
{
"freeMemoryIfNeeded"
,(
unsigned
long
)
freeMemoryIfNeeded
},
{
"freeOneObjectFromFreelist"
,(
unsigned
long
)
freeOneObjectFromFreelist
},
{
"freeOneObjectFromFreelist"
,(
unsigned
long
)
freeOneObjectFromFreelist
},
...
@@ -118,6 +120,7 @@ static struct redisFunctionSym symsTable[] = {
...
@@ -118,6 +120,7 @@ static struct redisFunctionSym symsTable[] = {
{
"processInputBuffer"
,(
unsigned
long
)
processInputBuffer
},
{
"processInputBuffer"
,(
unsigned
long
)
processInputBuffer
},
{
"pushGenericCommand"
,(
unsigned
long
)
pushGenericCommand
},
{
"pushGenericCommand"
,(
unsigned
long
)
pushGenericCommand
},
{
"qsortCompareSetsByCardinality"
,(
unsigned
long
)
qsortCompareSetsByCardinality
},
{
"qsortCompareSetsByCardinality"
,(
unsigned
long
)
qsortCompareSetsByCardinality
},
{
"queueIOJob"
,(
unsigned
long
)
queueIOJob
},
{
"queueMultiCommand"
,(
unsigned
long
)
queueMultiCommand
},
{
"queueMultiCommand"
,(
unsigned
long
)
queueMultiCommand
},
{
"randomkeyCommand"
,(
unsigned
long
)
randomkeyCommand
},
{
"randomkeyCommand"
,(
unsigned
long
)
randomkeyCommand
},
{
"rdbLoad"
,(
unsigned
long
)
rdbLoad
},
{
"rdbLoad"
,(
unsigned
long
)
rdbLoad
},
...
@@ -184,6 +187,7 @@ static struct redisFunctionSym symsTable[] = {
...
@@ -184,6 +187,7 @@ static struct redisFunctionSym symsTable[] = {
{
"smoveCommand"
,(
unsigned
long
)
smoveCommand
},
{
"smoveCommand"
,(
unsigned
long
)
smoveCommand
},
{
"sortCommand"
,(
unsigned
long
)
sortCommand
},
{
"sortCommand"
,(
unsigned
long
)
sortCommand
},
{
"sortCompare"
,(
unsigned
long
)
sortCompare
},
{
"sortCompare"
,(
unsigned
long
)
sortCompare
},
{
"spawnIOThread"
,(
unsigned
long
)
spawnIOThread
},
{
"spopCommand"
,(
unsigned
long
)
spopCommand
},
{
"spopCommand"
,(
unsigned
long
)
spopCommand
},
{
"srandmemberCommand"
,(
unsigned
long
)
srandmemberCommand
},
{
"srandmemberCommand"
,(
unsigned
long
)
srandmemberCommand
},
{
"sremCommand"
,(
unsigned
long
)
sremCommand
},
{
"sremCommand"
,(
unsigned
long
)
sremCommand
},
...
...
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