Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xindoo
redis
提交
09e1fe27
R
redis
项目概览
xindoo
/
redis
通知
2
Star
2
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,体验更适合开发者的 AI 搜索 >>
提交
09e1fe27
编写于
11月 04, 2019
作者:
L
Loris Cro
提交者:
antirez
11月 19, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix unreported overflow in autogerenared stream IDs
上级
7a7fbe70
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
19 addition
and
10 deletion
+19
-10
src/t_stream.c
src/t_stream.c
+13
-10
tests/unit/type/stream.tcl
tests/unit/type/stream.tcl
+6
-0
未找到文件。
src/t_stream.c
浏览文件 @
09e1fe27
...
...
@@ -173,9 +173,19 @@ int streamCompareID(streamID *a, streamID *b) {
* C_ERR if an ID was given via 'use_id', but adding it failed since the
* current top ID is greater or equal. */
int
streamAppendItem
(
stream
*
s
,
robj
**
argv
,
int64_t
numfields
,
streamID
*
added_id
,
streamID
*
use_id
)
{
/* If an ID was given, check that it's greater than the last entry ID
* or return an error. */
if
(
use_id
&&
streamCompareID
(
use_id
,
&
s
->
last_id
)
<=
0
)
return
C_ERR
;
/* Generate the new entry ID. */
streamID
id
;
if
(
use_id
)
id
=
*
use_id
;
else
streamNextID
(
&
s
->
last_id
,
&
id
);
/* Check that the new ID is greater than the last entry ID
* or return an error. Automatically generated IDs might
* overflow (and wrap-around) when incrementing the sequence
part. */
if
(
streamCompareID
(
&
id
,
&
s
->
last_id
)
<=
0
)
return
C_ERR
;
/* Add the new entry. */
raxIterator
ri
;
...
...
@@ -192,13 +202,6 @@ int streamAppendItem(stream *s, robj **argv, int64_t numfields, streamID *added_
}
raxStop
(
&
ri
);
/* Generate the new entry ID. */
streamID
id
;
if
(
use_id
)
id
=
*
use_id
;
else
streamNextID
(
&
s
->
last_id
,
&
id
);
/* We have to add the key into the radix tree in lexicographic order,
* to do so we consider the ID as a single 128 bit number written in
* big endian, so that the most significant bytes are the first ones. */
...
...
tests/unit/type/stream.tcl
浏览文件 @
09e1fe27
...
...
@@ -79,6 +79,12 @@ start_server {
assert
{[
streamCompareID $id2 $id3
]
== -1
}
}
test
{
XADD IDs correctly report an error when overflowing
}
{
r DEL mystream
r xadd mystream 18446744073709551615-18446744073709551615 a b
assert_error ERR*
{
r xadd mystream * c d
}
}
test
{
XADD with MAXLEN option
}
{
r DEL mystream
for
{
set j 0
}
{
$j
< 1000
}
{
incr j
}
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录