mirror of
https://github.com/fluencelabs/redis
synced 2025-03-23 11:00:50 +00:00
Lua debugger: clear end of session protocol.
When the debugger exits now it produces an <endsession> tag that informs redis-cli (or other debugging clients) that the session terminated. This way the client knows there is yet another reply to read (the one of the EVAL script itself), and can switch to non-debugging mode ASAP.
This commit is contained in:
parent
7492237c3c
commit
e386cd8ccf
@ -112,6 +112,7 @@ static struct config {
|
||||
char prompt[128];
|
||||
char *eval;
|
||||
int eval_ldb;
|
||||
int eval_ldb_end;
|
||||
int last_cmd_type;
|
||||
} config;
|
||||
|
||||
@ -377,14 +378,6 @@ static int cliConnect(int force) {
|
||||
if (context == NULL || force) {
|
||||
if (context != NULL) {
|
||||
redisFree(context);
|
||||
/* Disconnection from the server signals end of EVAL
|
||||
* debugging session. */
|
||||
if (config.eval_ldb) {
|
||||
printf("\n(Lua debugging session terminated)\n\n");
|
||||
config.eval_ldb = 0;
|
||||
config.output = OUTPUT_STANDARD;
|
||||
cliRefreshPrompt();
|
||||
}
|
||||
}
|
||||
|
||||
if (config.hostsocket == NULL) {
|
||||
@ -553,7 +546,16 @@ static sds cliFormatReplyRaw(redisReply *r) {
|
||||
/* The Lua debugger replies with arrays of simple (status)
|
||||
* strings. We colorize the output for more fun if this
|
||||
* is a debugging session. */
|
||||
out = sdsCatColorizedLdbReply(out,r->str,r->len);
|
||||
|
||||
/* Detect the end of a debugging session. */
|
||||
if (strstr(r->str,"<endsession>") == r->str) {
|
||||
config.eval_ldb = 0;
|
||||
config.eval_ldb_end = 1; /* Signal the caller session ended. */
|
||||
config.output = OUTPUT_STANDARD;
|
||||
cliRefreshPrompt();
|
||||
} else {
|
||||
out = sdsCatColorizedLdbReply(out,r->str,r->len);
|
||||
}
|
||||
} else {
|
||||
out = sdscatlen(out,r->str,r->len);
|
||||
}
|
||||
@ -1109,6 +1111,14 @@ static void repl(void) {
|
||||
|
||||
issueCommandRepeat(argc-skipargs, argv+skipargs, repeat);
|
||||
|
||||
/* If our debugging session ended, show the EVAL final
|
||||
* reply. */
|
||||
if (config.eval_ldb_end) {
|
||||
config.eval_ldb_end = 0;
|
||||
cliReadReply(0);
|
||||
printf("\n(Lua debugging session ended)\n\n");
|
||||
}
|
||||
|
||||
elapsed = mstime()-start_time;
|
||||
if (elapsed >= 500) {
|
||||
printf("(%.2fs)\n",(double)elapsed/1000);
|
||||
|
@ -1593,6 +1593,10 @@ int ldbStartSession(client *c) {
|
||||
/* End a debugging session after the EVAL call with debugging enabled
|
||||
* returned. */
|
||||
void ldbEndSession(client *c) {
|
||||
/* Emit the remaining logs and an <endsession> mark. */
|
||||
ldbLog(sdsnew("<endsession>"));
|
||||
ldbSendLogs();
|
||||
|
||||
/* If it's a fork()ed session, we just exit. */
|
||||
if (ldb.forked) {
|
||||
writeToClient(c->fd, c, 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user