| 3474 | } |
| 3475 | |
| 3476 | static struct command_result *json_graceful(struct command *cmd, |
| 3477 | const char *buffer, |
| 3478 | const jsmntok_t *obj UNNEEDED, |
| 3479 | const jsmntok_t *params) |
| 3480 | { |
| 3481 | struct graceful_waiter *gw = tal(cmd, struct graceful_waiter); |
| 3482 | u64 *timeout; |
| 3483 | |
| 3484 | if (!param(cmd, buffer, params, |
| 3485 | p_opt("timeout", param_u64, &timeout), |
| 3486 | NULL)) |
| 3487 | return command_param_failed(); |
| 3488 | |
| 3489 | log_unusual(cmd->ld->log, "JSON-RPC graceful: preventing more connections"); |
| 3490 | cmd->ld->state = LD_STATE_GRACE; |
| 3491 | |
| 3492 | gw->cmd = cmd; |
| 3493 | gw->last_msg = NULL; |
| 3494 | if (timeout) |
| 3495 | gw->timeout = new_reltimer(cmd->ld->timers, gw, |
| 3496 | time_from_sec(*timeout), |
| 3497 | graceful_timeout, gw); |
| 3498 | list_add_tail(&cmd->ld->graceful_commands, &gw->list); |
| 3499 | tal_add_destructor(gw, destroy_graceful_waiter); |
| 3500 | return check_graceful_shutdown_progress(cmd->ld, cmd); |
| 3501 | } |
| 3502 | |
| 3503 | static const struct json_command graceful_command = { |
| 3504 | "graceful", |
nothing calls this directly
no test coverage detected