Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
hanoi2005
redis
提交
3d73f088
R
redis
项目概览
hanoi2005
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
提交
3d73f088
编写于
12月 01, 2014
作者:
A
azure provisioned user
提交者:
antirez
12月 09, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
redis-benchmark AUTH command to be discarded after the first send #2150
上级
76d53a67
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
30 addition
and
28 deletion
+30
-28
src/redis-benchmark.c
src/redis-benchmark.c
+30
-28
未找到文件。
src/redis-benchmark.c
浏览文件 @
3d73f088
...
...
@@ -90,9 +90,10 @@ typedef struct _client {
long
long
start
;
/* Start time of a request */
long
long
latency
;
/* Request latency */
int
pending
;
/* Number of pending requests (replies to consume) */
int
selectlen
;
/* If non-zero, a SELECT of 'selectlen' bytes is currently
used as a prefix of the pipline of commands. This gets
discarded the first time it's sent. */
int
prefix_pending
;
/* If non-zero, number of pending prefix commands. Commands
such as auth and select are prefixed to the pipeline of
benchmark commands and discarded after the first send. */
int
prefixlen
;
/* Size in bytes of the pending prefix commands */
}
*
client
;
/* Prototypes */
...
...
@@ -212,20 +213,21 @@ static void readHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
}
freeReplyObject
(
reply
);
if
(
c
->
selectlen
)
{
size_t
j
;
/* This is the OK from SELECT. Just discard the SELECT
* from the buffer. */
// This is an OK for prefix commands such as auth and select.
if
(
c
->
prefix_pending
>
0
)
{
c
->
prefix_pending
--
;
c
->
pending
--
;
sdsrange
(
c
->
obuf
,
c
->
selectlen
,
-
1
);
/* We also need to fix the pointers to the strings
* we need to randomize. */
for
(
j
=
0
;
j
<
c
->
randlen
;
j
++
)
c
->
randptr
[
j
]
-=
c
->
selectlen
;
c
->
selectlen
=
0
;
continue
;
// Discard prefix commands on first response.
if
(
c
->
prefixlen
>
0
)
{
size_t
j
;
sdsrange
(
c
->
obuf
,
c
->
prefixlen
,
-
1
);
/* We also need to fix the pointers to the strings
* we need to randomize. */
for
(
j
=
0
;
j
<
c
->
randlen
;
j
++
)
c
->
randptr
[
j
]
-=
c
->
prefixlen
;
c
->
prefixlen
=
0
;
}
continue
;
}
if
(
config
.
requests_finished
<
config
.
requests
)
...
...
@@ -299,8 +301,7 @@ static void writeHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
* 2) The offsets of the __rand_int__ elements inside the command line, used
* for arguments randomization.
*
* Even when cloning another client, the SELECT command is automatically prefixed
* if needed. */
* Even when cloning another client, prefix commands are applied if needed.*/
static
client
createClient
(
char
*
cmd
,
size_t
len
,
client
from
)
{
int
j
;
client
c
=
zmalloc
(
sizeof
(
struct
_client
));
...
...
@@ -325,12 +326,16 @@ static client createClient(char *cmd, size_t len, client from) {
* Queue N requests accordingly to the pipeline size, or simply clone
* the example client buffer. */
c
->
obuf
=
sdsempty
();
/* Prefix the request buffer with AUTH and/or SELECT commands, if applicable.
* These commands are discarded after the first response, so if the client is
* reused the commands will not be used again. */
c
->
prefix_pending
=
0
;
if
(
config
.
auth
)
{
char
*
buf
=
NULL
;
int
len
=
redisFormatCommand
(
&
buf
,
"AUTH %s"
,
config
.
auth
);
c
->
obuf
=
sdscatlen
(
c
->
obuf
,
buf
,
len
);
free
(
buf
);
c
->
prefix_pending
++
;
}
/* If a DB number different than zero is selected, prefix our request
...
...
@@ -340,26 +345,23 @@ static client createClient(char *cmd, size_t len, client from) {
if
(
config
.
dbnum
!=
0
)
{
c
->
obuf
=
sdscatprintf
(
c
->
obuf
,
"*2
\r\n
$6
\r\n
SELECT
\r\n
$%d
\r\n
%s
\r\n
"
,
(
int
)
sdslen
(
config
.
dbnumstr
),
config
.
dbnumstr
);
c
->
selectlen
=
sdslen
(
c
->
obuf
);
}
else
{
c
->
selectlen
=
0
;
c
->
prefix_pending
++
;
}
c
->
prefixlen
=
sdslen
(
c
->
obuf
);
/* Append the request itself. */
if
(
from
)
{
c
->
obuf
=
sdscatlen
(
c
->
obuf
,
from
->
obuf
+
from
->
select
len
,
sdslen
(
from
->
obuf
)
-
from
->
select
len
);
from
->
obuf
+
from
->
prefix
len
,
sdslen
(
from
->
obuf
)
-
from
->
prefix
len
);
}
else
{
for
(
j
=
0
;
j
<
config
.
pipeline
;
j
++
)
c
->
obuf
=
sdscatlen
(
c
->
obuf
,
cmd
,
len
);
}
c
->
written
=
0
;
c
->
pending
=
config
.
pipeline
;
c
->
pending
=
config
.
pipeline
+
c
->
prefix_pending
;
c
->
randptr
=
NULL
;
c
->
randlen
=
0
;
if
(
c
->
selectlen
)
c
->
pending
++
;
/* Find substrings in the output buffer that need to be randomized. */
if
(
config
.
randomkeys
)
{
...
...
@@ -371,7 +373,7 @@ static client createClient(char *cmd, size_t len, client from) {
for
(
j
=
0
;
j
<
(
int
)
c
->
randlen
;
j
++
)
{
c
->
randptr
[
j
]
=
c
->
obuf
+
(
from
->
randptr
[
j
]
-
from
->
obuf
);
/* Adjust for the different select prefix length. */
c
->
randptr
[
j
]
+=
c
->
selectlen
-
from
->
select
len
;
c
->
randptr
[
j
]
+=
c
->
prefixlen
-
from
->
prefix
len
;
}
}
else
{
char
*
p
=
c
->
obuf
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录