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
fcb3aef7
Commit
fcb3aef7
authored
Oct 13, 2015
by
antirez
Browse files
DEBUG RESTART/CRASH-AND-RECOVER [delay] implemented.
parent
1db84c21
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/debug.c
View file @
fcb3aef7
...
@@ -261,6 +261,20 @@ void inputCatSds(void *result, const char *str) {
...
@@ -261,6 +261,20 @@ void inputCatSds(void *result, const char *str) {
void debugCommand(client *c) {
void debugCommand(client *c) {
if (!strcasecmp(c->argv[1]->ptr,"segfault")) {
if (!strcasecmp(c->argv[1]->ptr,"segfault")) {
*((char*)-1) = 'x';
*((char*)-1) = 'x';
} else if (!strcasecmp(c->argv[1]->ptr,"restart") ||
!strcasecmp(c->argv[1]->ptr,"crash-and-recover"))
{
long long delay = 0;
if (c->argc >= 3) {
if (getLongLongFromObjectOrReply(c, c->argv[2], &delay, NULL)
!= C_OK) return;
if (delay < 0) delay = 0;
}
int flags = !strcasecmp(c->argv[1]->ptr,"restart") ?
(RESTART_SERVER_GRACEFULLY|RESTART_SERVER_CONFIG_REWRITE) :
RESTART_SERVER_NONE;
restartServer(flags,delay);
addReplyError(c,"failed to restart the server. Check server logs.");
} else if (!strcasecmp(c->argv[1]->ptr,"oom")) {
} else if (!strcasecmp(c->argv[1]->ptr,"oom")) {
void *ptr = zmalloc(ULONG_MAX); /* Should trigger an out of memory. */
void *ptr = zmalloc(ULONG_MAX); /* Should trigger an out of memory. */
zfree(ptr);
zfree(ptr);
...
...
src/server.c
View file @
fcb3aef7
...
@@ -1579,6 +1579,9 @@ extern char **environ;
...
@@ -1579,6 +1579,9 @@ extern char **environ;
/* Restart the server, executing the same executable that started this
/* Restart the server, executing the same executable that started this
* instance, with the same arguments and configuration file.
* instance, with the same arguments and configuration file.
*
*
* The function is designed to directly call execve() so that the new
* server instance will retain the PID of the previous one.
*
* The list of flags, that may be bitwise ORed together, alter the
* The list of flags, that may be bitwise ORed together, alter the
* behavior of this function:
* behavior of this function:
*
*
...
...
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