Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
别团等shy哥发育
redis
提交
5f6e1183
R
redis
项目概览
别团等shy哥发育
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5f6e1183
编写于
12月 29, 2010
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
implemented complete job handling
上级
f34a6cd8
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
6 addition
and
60 deletion
+6
-60
src/dscache.c
src/dscache.c
+6
-60
未找到文件。
src/dscache.c
浏览文件 @
5f6e1183
...
...
@@ -240,6 +240,7 @@ int dsCanTouchDiskStore(void) {
void
freeIOJob
(
iojob
*
j
)
{
decrRefCount
(
j
->
key
);
decrRefCount
(
j
->
val
);
zfree
(
j
);
}
...
...
@@ -282,68 +283,13 @@ void vmThreadedIOCompletedJob(aeEventLoop *el, int fd, void *privdata,
de
=
dictFind
(
j
->
db
->
dict
,
j
->
key
->
ptr
);
redisAssert
(
de
!=
NULL
);
if
(
j
->
type
==
REDIS_IOJOB_LOAD
)
{
redisDb
*
db
;
vmpointer
*
vp
=
dictGetEntryVal
(
de
);
/* Key loaded, bring it at home */
vmMarkPagesFree
(
vp
->
page
,
vp
->
usedpages
);
redisLog
(
REDIS_DEBUG
,
"VM: object %s loaded from disk (threaded)"
,
(
unsigned
char
*
)
j
->
key
->
ptr
);
server
.
vm_stats_swapped_objects
--
;
server
.
vm_stats_swapins
++
;
dictGetEntryVal
(
de
)
=
j
->
val
;
incrRefCount
(
j
->
val
);
db
=
j
->
db
;
/* Handle clients waiting for this key to be loaded. */
handleClientsBlockedOnSwappedKey
(
db
,
j
->
key
);
dbAdd
(
j
->
db
,
j
->
key
,
j
->
val
);
freeIOJob
(
j
);
zfree
(
vp
);
}
else
if
(
j
->
type
==
REDIS_IOJOB_DO_SWAP
)
{
vmpointer
*
vp
;
/* Key swapped. We can finally free some memory. */
if
(
j
->
val
->
storage
!=
REDIS_VM_SWAPPING
)
{
vmpointer
*
vp
=
(
vmpointer
*
)
j
->
id
;
printf
(
"storage: %d
\n
"
,
vp
->
storage
);
printf
(
"key->name: %s
\n
"
,(
char
*
)
j
->
key
->
ptr
);
printf
(
"val: %p
\n
"
,(
void
*
)
j
->
val
);
printf
(
"val->type: %d
\n
"
,
j
->
val
->
type
);
printf
(
"val->ptr: %s
\n
"
,(
char
*
)
j
->
val
->
ptr
);
}
redisAssert
(
j
->
val
->
storage
==
REDIS_VM_SWAPPING
);
vp
=
createVmPointer
(
j
->
val
->
type
);
vp
->
page
=
j
->
page
;
vp
->
usedpages
=
j
->
pages
;
dictGetEntryVal
(
de
)
=
vp
;
/* Fix the storage otherwise decrRefCount will attempt to
* remove the associated I/O job */
j
->
val
->
storage
=
REDIS_VM_MEMORY
;
decrRefCount
(
j
->
val
);
redisLog
(
REDIS_DEBUG
,
"VM: object %s swapped out at %lld (%lld pages) (threaded)"
,
(
unsigned
char
*
)
j
->
key
->
ptr
,
(
unsigned
long
long
)
j
->
page
,
(
unsigned
long
long
)
j
->
pages
);
server
.
vm_stats_swapped_objects
++
;
server
.
vm_stats_swapouts
++
;
/* FIXME: notify clients waiting for this key */
}
else
if
(
j
->
type
==
REDIS_IOJOB_SAVE
)
{
redisAssert
(
j
->
val
->
storage
==
REDIS_DS_SAVING
);
j
->
val
->
storage
=
REDIS_DS_MEMORY
;
freeIOJob
(
j
);
/* Put a few more swap requests in queue if we are still
* out of memory */
if
(
trytoswap
&&
vmCanSwapOut
()
&&
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
)
{
trytoswap
=
0
;
break
;
}
}
}
}
processed
++
;
if
(
processed
==
toprocess
)
return
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录