Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
别团等shy哥发育
redis
提交
12a042f8
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,发现更多精彩内容 >>
提交
12a042f8
编写于
4月 24, 2012
作者:
A
antirez
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
redis-check-dump now is RDB version 6 ready.
上级
717145c1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
36 addition
and
4 deletion
+36
-4
src/Makefile
src/Makefile
+1
-1
src/redis-check-dump.c
src/redis-check-dump.c
+35
-3
未找到文件。
src/Makefile
浏览文件 @
12a042f8
...
@@ -102,7 +102,7 @@ REDIS_CLI_OBJ= anet.o sds.o adlist.o redis-cli.o zmalloc.o release.o
...
@@ -102,7 +102,7 @@ REDIS_CLI_OBJ= anet.o sds.o adlist.o redis-cli.o zmalloc.o release.o
REDIS_BENCHMARK_NAME
=
redis-benchmark
REDIS_BENCHMARK_NAME
=
redis-benchmark
REDIS_BENCHMARK_OBJ
=
ae.o anet.o redis-benchmark.o sds.o adlist.o zmalloc.o redis-benchmark.o
REDIS_BENCHMARK_OBJ
=
ae.o anet.o redis-benchmark.o sds.o adlist.o zmalloc.o redis-benchmark.o
REDIS_CHECK_DUMP_NAME
=
redis-check-dump
REDIS_CHECK_DUMP_NAME
=
redis-check-dump
REDIS_CHECK_DUMP_OBJ
=
redis-check-dump.o lzf_c.o lzf_d.o
REDIS_CHECK_DUMP_OBJ
=
redis-check-dump.o lzf_c.o lzf_d.o
crc64.o
REDIS_CHECK_AOF_NAME
=
redis-check-aof
REDIS_CHECK_AOF_NAME
=
redis-check-aof
REDIS_CHECK_AOF_OBJ
=
redis-check-aof.o
REDIS_CHECK_AOF_OBJ
=
redis-check-aof.o
...
...
src/redis-check-dump.c
浏览文件 @
12a042f8
...
@@ -108,6 +108,9 @@ static double R_Zero, R_PosInf, R_NegInf, R_Nan;
...
@@ -108,6 +108,9 @@ static double R_Zero, R_PosInf, R_NegInf, R_Nan;
/* store string types for output */
/* store string types for output */
static
char
types
[
256
][
16
];
static
char
types
[
256
][
16
];
/* Prototypes */
uint64_t
crc64
(
uint64_t
crc
,
const
unsigned
char
*
s
,
uint64_t
l
);
/* when number of bytes to read is negative, do a peek */
/* when number of bytes to read is negative, do a peek */
int
readBytes
(
void
*
target
,
long
num
)
{
int
readBytes
(
void
*
target
,
long
num
)
{
char
peek
=
(
num
<
0
)
?
1
:
0
;
char
peek
=
(
num
<
0
)
?
1
:
0
;
...
@@ -137,10 +140,10 @@ int processHeader() {
...
@@ -137,10 +140,10 @@ int processHeader() {
}
}
dump_version
=
(
int
)
strtol
(
buf
+
5
,
NULL
,
10
);
dump_version
=
(
int
)
strtol
(
buf
+
5
,
NULL
,
10
);
if
(
dump_version
<
1
||
dump_version
>
4
)
{
if
(
dump_version
<
1
||
dump_version
>
6
)
{
ERROR
(
"Unknown RDB format version: %d
\n
"
,
dump_version
);
ERROR
(
"Unknown RDB format version: %d
\n
"
,
dump_version
);
}
}
return
1
;
return
dump_version
;
}
}
int
loadType
(
entry
*
e
)
{
int
loadType
(
entry
*
e
)
{
...
@@ -557,7 +560,16 @@ void printErrorStack(entry *e) {
...
@@ -557,7 +560,16 @@ void printErrorStack(entry *e) {
void
process
()
{
void
process
()
{
uint64_t
num_errors
=
0
,
num_valid_ops
=
0
,
num_valid_bytes
=
0
;
uint64_t
num_errors
=
0
,
num_valid_ops
=
0
,
num_valid_bytes
=
0
;
entry
entry
;
entry
entry
;
processHeader
();
int
dump_version
=
processHeader
();
/* Exclude the final checksum for RDB >= 5. Will be checked at the end. */
if
(
dump_version
>=
5
)
{
if
(
positions
[
0
].
size
<
8
)
{
printf
(
"RDB version >= 5 but no room for checksum.
\n
"
);
exit
(
1
);
}
positions
[
0
].
size
-=
8
;;
}
level
=
1
;
level
=
1
;
while
(
positions
[
0
].
offset
<
positions
[
0
].
size
)
{
while
(
positions
[
0
].
offset
<
positions
[
0
].
size
)
{
...
@@ -622,6 +634,26 @@ void process() {
...
@@ -622,6 +634,26 @@ void process() {
num_errors
++
;
num_errors
++
;
}
}
/* Verify checksum */
if
(
dump_version
>=
5
)
{
uint64_t
crc
=
crc64
(
0
,
positions
[
0
].
data
,
positions
[
0
].
size
);
uint64_t
crc2
;
unsigned
char
*
p
=
(
unsigned
char
*
)
positions
[
0
].
data
+
positions
[
0
].
size
;
crc2
=
((
uint64_t
)
p
[
0
]
<<
0
)
|
((
uint64_t
)
p
[
1
]
<<
8
)
|
((
uint64_t
)
p
[
2
]
<<
16
)
|
((
uint64_t
)
p
[
3
]
<<
24
)
|
((
uint64_t
)
p
[
4
]
<<
32
)
|
((
uint64_t
)
p
[
5
]
<<
40
)
|
((
uint64_t
)
p
[
6
]
<<
48
)
|
((
uint64_t
)
p
[
7
]
<<
56
);
if
(
crc
!=
crc2
)
{
SHIFT_ERROR
(
positions
[
0
].
offset
,
"RDB CRC64 does not match."
);
}
else
{
printf
(
"CRC64 checksum is OK
\n
"
);
}
}
/* print summary on errors */
/* print summary on errors */
if
(
num_errors
)
{
if
(
num_errors
)
{
printf
(
"
\n
"
);
printf
(
"
\n
"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录