diff options
author | minkikim89 <minkikim89@gmail.com> | 2020-12-27 15:33:02 +0900 |
---|---|---|
committer | dormando <dormando@rydia.net> | 2021-06-07 21:54:10 -0700 |
commit | 02305885e3d9d82fb1cd00a5869ce1fb49cfb62a (patch) | |
tree | 45e0bb7f17428bcbd3083ba1c06a0de458806bdb /proto_text.c | |
parent | 585d03f198c5907c9a07f97fa89bb7b9851a874e (diff) | |
download | memcached-02305885e3d9d82fb1cd00a5869ce1fb49cfb62a.tar.gz |
Added debugtime command
Diffstat (limited to 'proto_text.c')
-rw-r--r-- | proto_text.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/proto_text.c b/proto_text.c index ecc6f92..f173020 100644 --- a/proto_text.c +++ b/proto_text.c @@ -2067,6 +2067,31 @@ static void process_misbehave_command(conn *c) { out_string(c, "OK"); } } + +static void process_debugtime_command(conn *c, token_t *tokens, const size_t ntokens) { + struct timeval tv; + + if (strcmp(tokens[1].value, "p") == 0) { + gettimeofday(&tv, NULL); + if (!is_paused) { + is_paused = true; + } + } else if (strcmp(tokens[1].value, "r") == 0) { + gettimeofday(&tv, NULL); + if (is_paused) { + is_paused = false; + } + } else { + int64_t time_delta = 0; + if (!safe_strtoll(tokens[1].value, &time_delta)) { + out_string(c, "ERROR"); + return; + } + delta += time_delta; + current_time += delta; + } + out_string(c, "OK"); +} #endif static void process_slabs_automove_command(conn *c, token_t *tokens, const size_t ntokens) { @@ -2673,6 +2698,11 @@ static void process_command(conn *c, char *command) { WANT_TOKENS_OR(ntokens, 4, 5); process_arithmetic_command(c, tokens, ntokens, 0); +#ifdef MEMCACHED_DEBUG + } else if (strcmp(tokens[COMMAND_TOKEN].value, "debugtime") == 0) { + WANT_TOKENS_MIN(ntokens, 2); + process_debugtime_command(c, tokens, ntokens); +#endif } else { out_string(c, "ERROR"); } |