mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
lightningd: avoid plugin timer indirection.
Now we know whether the command completed or not, we can correctly call command_still_pending() if it didn't complete. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -774,11 +774,6 @@ REGISTER_SINGLE_PLUGIN_HOOK(rpc_command,
|
|||||||
rpc_command_hook_serialize,
|
rpc_command_hook_serialize,
|
||||||
struct rpc_command_hook_payload *);
|
struct rpc_command_hook_payload *);
|
||||||
|
|
||||||
static void call_rpc_command_hook(struct rpc_command_hook_payload *p)
|
|
||||||
{
|
|
||||||
plugin_hook_call_rpc_command(p->cmd->ld, p);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We return struct command_result so command_fail return value has a natural
|
/* We return struct command_result so command_fail return value has a natural
|
||||||
* sink; we don't actually use the result. */
|
* sink; we don't actually use the result. */
|
||||||
static struct command_result *
|
static struct command_result *
|
||||||
@@ -787,6 +782,7 @@ parse_request(struct json_connection *jcon, const jsmntok_t tok[])
|
|||||||
const jsmntok_t *method, *id, *params;
|
const jsmntok_t *method, *id, *params;
|
||||||
struct command *c;
|
struct command *c;
|
||||||
struct rpc_command_hook_payload *rpc_hook;
|
struct rpc_command_hook_payload *rpc_hook;
|
||||||
|
bool completed;
|
||||||
|
|
||||||
if (tok[0].type != JSMN_OBJECT) {
|
if (tok[0].type != JSMN_OBJECT) {
|
||||||
json_command_malformed(jcon, "null",
|
json_command_malformed(jcon, "null",
|
||||||
@@ -850,11 +846,15 @@ parse_request(struct json_connection *jcon, const jsmntok_t tok[])
|
|||||||
/* Duplicate since we might outlive the connection */
|
/* Duplicate since we might outlive the connection */
|
||||||
rpc_hook->buffer = tal_dup_talarr(rpc_hook, char, jcon->buffer);
|
rpc_hook->buffer = tal_dup_talarr(rpc_hook, char, jcon->buffer);
|
||||||
rpc_hook->request = tal_dup_talarr(rpc_hook, jsmntok_t, tok);
|
rpc_hook->request = tal_dup_talarr(rpc_hook, jsmntok_t, tok);
|
||||||
/* Prevent a race between was_pending and still_pending */
|
|
||||||
new_reltimer(c->ld->timers, rpc_hook, time_from_msec(1),
|
|
||||||
call_rpc_command_hook, rpc_hook);
|
|
||||||
|
|
||||||
|
db_begin_transaction(jcon->ld->wallet->db);
|
||||||
|
completed = plugin_hook_call_rpc_command(jcon->ld, rpc_hook);
|
||||||
|
db_commit_transaction(jcon->ld->wallet->db);
|
||||||
|
|
||||||
|
/* If it's deferred, mark it (otherwise, it's completed) */
|
||||||
|
if (!completed)
|
||||||
return command_still_pending(c);
|
return command_still_pending(c);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mutual recursion */
|
/* Mutual recursion */
|
||||||
|
|||||||
@@ -9,6 +9,12 @@ size_t bigsize_get(const u8 *p UNNEEDED, size_t max UNNEEDED, bigsize_t *val UNN
|
|||||||
/* Generated stub for bigsize_put */
|
/* Generated stub for bigsize_put */
|
||||||
size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED)
|
size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED)
|
||||||
{ fprintf(stderr, "bigsize_put called!\n"); abort(); }
|
{ fprintf(stderr, "bigsize_put called!\n"); abort(); }
|
||||||
|
/* Generated stub for db_begin_transaction_ */
|
||||||
|
void db_begin_transaction_(struct db *db UNNEEDED, const char *location UNNEEDED)
|
||||||
|
{ fprintf(stderr, "db_begin_transaction_ called!\n"); abort(); }
|
||||||
|
/* Generated stub for db_commit_transaction */
|
||||||
|
void db_commit_transaction(struct db *db UNNEEDED)
|
||||||
|
{ fprintf(stderr, "db_commit_transaction called!\n"); abort(); }
|
||||||
/* Generated stub for fatal */
|
/* Generated stub for fatal */
|
||||||
void fatal(const char *fmt UNNEEDED, ...)
|
void fatal(const char *fmt UNNEEDED, ...)
|
||||||
{ fprintf(stderr, "fatal called!\n"); abort(); }
|
{ fprintf(stderr, "fatal called!\n"); abort(); }
|
||||||
|
|||||||
Reference in New Issue
Block a user