Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
920611a4
Commit
920611a4
authored
Nov 30, 2018
by
antirez
Browse files
RESP3: latency.c updated.
parent
ddb98ad5
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/latency.c
View file @
920611a4
...
@@ -476,19 +476,19 @@ sds createLatencyReport(void) {
...
@@ -476,19 +476,19 @@ sds createLatencyReport(void) {
/* latencyCommand() helper to produce a time-delay reply for all the samples
/* latencyCommand() helper to produce a time-delay reply for all the samples
* in memory for the specified time series. */
* in memory for the specified time series. */
void
latencyCommandReplyWithSamples
(
client
*
c
,
struct
latencyTimeSeries
*
ts
)
{
void
latencyCommandReplyWithSamples
(
client
*
c
,
struct
latencyTimeSeries
*
ts
)
{
void
*
replylen
=
addDeferred
MultiBulkLength
(
c
);
void
*
replylen
=
add
Reply
Deferred
Len
(
c
);
int
samples
=
0
,
j
;
int
samples
=
0
,
j
;
for
(
j
=
0
;
j
<
LATENCY_TS_LEN
;
j
++
)
{
for
(
j
=
0
;
j
<
LATENCY_TS_LEN
;
j
++
)
{
int
i
=
(
ts
->
idx
+
j
)
%
LATENCY_TS_LEN
;
int
i
=
(
ts
->
idx
+
j
)
%
LATENCY_TS_LEN
;
if
(
ts
->
samples
[
i
].
time
==
0
)
continue
;
if
(
ts
->
samples
[
i
].
time
==
0
)
continue
;
addReply
MultiBulk
Len
(
c
,
2
);
addReply
Array
Len
(
c
,
2
);
addReplyLongLong
(
c
,
ts
->
samples
[
i
].
time
);
addReplyLongLong
(
c
,
ts
->
samples
[
i
].
time
);
addReplyLongLong
(
c
,
ts
->
samples
[
i
].
latency
);
addReplyLongLong
(
c
,
ts
->
samples
[
i
].
latency
);
samples
++
;
samples
++
;
}
}
setDeferred
MultiBulkLength
(
c
,
replylen
,
samples
);
setDeferred
ArrayLen
(
c
,
replylen
,
samples
);
}
}
/* latencyCommand() helper to produce the reply for the LATEST subcommand,
/* latencyCommand() helper to produce the reply for the LATEST subcommand,
...
@@ -497,14 +497,14 @@ void latencyCommandReplyWithLatestEvents(client *c) {
...
@@ -497,14 +497,14 @@ void latencyCommandReplyWithLatestEvents(client *c) {
dictIterator
*
di
;
dictIterator
*
di
;
dictEntry
*
de
;
dictEntry
*
de
;
addReply
MultiBulk
Len
(
c
,
dictSize
(
server
.
latency_events
));
addReply
Array
Len
(
c
,
dictSize
(
server
.
latency_events
));
di
=
dictGetIterator
(
server
.
latency_events
);
di
=
dictGetIterator
(
server
.
latency_events
);
while
((
de
=
dictNext
(
di
))
!=
NULL
)
{
while
((
de
=
dictNext
(
di
))
!=
NULL
)
{
char
*
event
=
dictGetKey
(
de
);
char
*
event
=
dictGetKey
(
de
);
struct
latencyTimeSeries
*
ts
=
dictGetVal
(
de
);
struct
latencyTimeSeries
*
ts
=
dictGetVal
(
de
);
int
last
=
(
ts
->
idx
+
LATENCY_TS_LEN
-
1
)
%
LATENCY_TS_LEN
;
int
last
=
(
ts
->
idx
+
LATENCY_TS_LEN
-
1
)
%
LATENCY_TS_LEN
;
addReply
MultiBulk
Len
(
c
,
4
);
addReply
Array
Len
(
c
,
4
);
addReplyBulkCString
(
c
,
event
);
addReplyBulkCString
(
c
,
event
);
addReplyLongLong
(
c
,
ts
->
samples
[
last
].
time
);
addReplyLongLong
(
c
,
ts
->
samples
[
last
].
time
);
addReplyLongLong
(
c
,
ts
->
samples
[
last
].
latency
);
addReplyLongLong
(
c
,
ts
->
samples
[
last
].
latency
);
...
@@ -583,7 +583,7 @@ NULL
...
@@ -583,7 +583,7 @@ NULL
/* LATENCY HISTORY <event> */
/* LATENCY HISTORY <event> */
ts
=
dictFetchValue
(
server
.
latency_events
,
c
->
argv
[
2
]
->
ptr
);
ts
=
dictFetchValue
(
server
.
latency_events
,
c
->
argv
[
2
]
->
ptr
);
if
(
ts
==
NULL
)
{
if
(
ts
==
NULL
)
{
addReply
MultiBulk
Len
(
c
,
0
);
addReply
Array
Len
(
c
,
0
);
}
else
{
}
else
{
latencyCommandReplyWithSamples
(
c
,
ts
);
latencyCommandReplyWithSamples
(
c
,
ts
);
}
}
...
...
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