mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 07:34:24 +01:00
JSON RPC: Calls made in shutdown loop receive error code -5: LIGHTNINGD_SHUTDOWN
This commit is contained in:
committed by
Rusty Russell
parent
209614677a
commit
0388314ef8
@@ -28,6 +28,9 @@ static const errcode_t PLUGIN_ERROR = -3;
|
|||||||
/* Plugin terminated while handling a request. */
|
/* Plugin terminated while handling a request. */
|
||||||
static const errcode_t PLUGIN_TERMINATED = -4;
|
static const errcode_t PLUGIN_TERMINATED = -4;
|
||||||
|
|
||||||
|
/* Lightningd is shutting down while handling a request. */
|
||||||
|
static const errcode_t LIGHTNINGD_SHUTDOWN = -5;
|
||||||
|
|
||||||
/* Errors from `pay`, `sendpay`, or `waitsendpay` commands */
|
/* Errors from `pay`, `sendpay`, or `waitsendpay` commands */
|
||||||
static const errcode_t PAY_IN_PROGRESS = 200;
|
static const errcode_t PAY_IN_PROGRESS = 200;
|
||||||
static const errcode_t PAY_RHASH_ALREADY_USED = 201;
|
static const errcode_t PAY_RHASH_ALREADY_USED = 201;
|
||||||
|
|||||||
@@ -933,6 +933,11 @@ parse_request(struct json_connection *jcon, const jsmntok_t tok[])
|
|||||||
json_tok_full(jcon->buffer, method));
|
json_tok_full(jcon->buffer, method));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (jcon->ld->state == LD_STATE_SHUTDOWN) {
|
||||||
|
return command_fail(c, LIGHTNINGD_SHUTDOWN,
|
||||||
|
"lightningd is shutting down");
|
||||||
|
}
|
||||||
|
|
||||||
rpc_hook = tal(c, struct rpc_command_hook_payload);
|
rpc_hook = tal(c, struct rpc_command_hook_payload);
|
||||||
rpc_hook->cmd = c;
|
rpc_hook->cmd = c;
|
||||||
/* Duplicate since we might outlive the connection */
|
/* Duplicate since we might outlive the connection */
|
||||||
|
|||||||
@@ -1168,6 +1168,8 @@ int main(int argc, char *argv[])
|
|||||||
* shut down.
|
* shut down.
|
||||||
*/
|
*/
|
||||||
assert(io_loop_ret == ld);
|
assert(io_loop_ret == ld);
|
||||||
|
|
||||||
|
/* Fail JSON RPC requests and ignore plugin's responses */
|
||||||
ld->state = LD_STATE_SHUTDOWN;
|
ld->state = LD_STATE_SHUTDOWN;
|
||||||
|
|
||||||
stop_fd = -1;
|
stop_fd = -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user