Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
dc44326f
Commit
dc44326f
authored
Jul 22, 2010
by
antirez
Browse files
recent VM fixes backported to 2.0.0 branch
parent
d8f25ce3
Changes
1
Hide whitespace changes
Inline
Side-by-side
redis.c
View file @
dc44326f
...
@@ -342,6 +342,7 @@ struct saveparam {
...
@@ -342,6 +342,7 @@ struct saveparam {
/* Global server state structure */
/* Global server state structure */
struct
redisServer
{
struct
redisServer
{
pthread_t
mainthread
;
int
port
;
int
port
;
int
fd
;
int
fd
;
redisDb
*
db
;
redisDb
*
db
;
...
@@ -1725,6 +1726,7 @@ static void initServer() {
...
@@ -1725,6 +1726,7 @@ static void initServer() {
signal
(
SIGPIPE
,
SIG_IGN
);
signal
(
SIGPIPE
,
SIG_IGN
);
setupSigSegvAction
();
setupSigSegvAction
();
server
.
mainthread
=
pthread_self
();
server
.
devnull
=
fopen
(
"/dev/null"
,
"w"
);
server
.
devnull
=
fopen
(
"/dev/null"
,
"w"
);
if
(
server
.
devnull
==
NULL
)
{
if
(
server
.
devnull
==
NULL
)
{
redisLog
(
REDIS_WARNING
,
"Can't open /dev/null: %s"
,
server
.
neterr
);
redisLog
(
REDIS_WARNING
,
"Can't open /dev/null: %s"
,
server
.
neterr
);
...
@@ -2930,7 +2932,8 @@ static robj *createStringObject(char *ptr, size_t len) {
...
@@ -2930,7 +2932,8 @@ static robj *createStringObject(char *ptr, size_t len) {
static
robj
*
createStringObjectFromLongLong
(
long
long
value
)
{
static
robj
*
createStringObjectFromLongLong
(
long
long
value
)
{
robj
*
o
;
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
]);
incrRefCount
(
shared
.
integers
[
value
]);
o
=
shared
.
integers
[
value
];
o
=
shared
.
integers
[
value
];
}
else
{
}
else
{
...
@@ -3182,8 +3185,15 @@ static robj *tryObjectEncoding(robj *o) {
...
@@ -3182,8 +3185,15 @@ static robj *tryObjectEncoding(robj *o) {
/* Check if we can represent this string as a long integer */
/* Check if we can represent this string as a long integer */
if
(
isStringRepresentableAsLong
(
s
,
&
value
)
==
REDIS_ERR
)
return
o
;
if
(
isStringRepresentableAsLong
(
s
,
&
value
)
==
REDIS_ERR
)
return
o
;
/* Ok, this object can be encoded */
/* Ok, this object can be encoded...
if
(
value
>=
0
&&
value
<
REDIS_SHARED_INTEGERS
)
{
*
* Can I use a shared object? Only if the object is inside a given
* 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). */
if
(
value
>=
0
&&
value
<
REDIS_SHARED_INTEGERS
&&
pthread_equal
(
pthread_self
(),
server
.
mainthread
))
{
decrRefCount
(
o
);
decrRefCount
(
o
);
incrRefCount
(
shared
.
integers
[
value
]);
incrRefCount
(
shared
.
integers
[
value
]);
return
shared
.
integers
[
value
];
return
shared
.
integers
[
value
];
...
...
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