Skip to content

Commit 31f44f6

Browse files
recklessrpc: fixup close connection
1 parent 30f1e2e commit 31f44f6

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

plugins/recklessrpc.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,8 @@ static void dup_listavailable_result(struct reckless *reckless,
112112
json_array_end(response);
113113
}
114114

115-
static struct command_result *reckless_result(struct io_conn *conn,
116-
struct reckless *reckless)
115+
static struct command_result *reckless_result(struct reckless *reckless)
117116
{
118-
io_close(conn);
119117
struct json_stream *response;
120118
if (reckless->process_failed) {
121119
response = jsonrpc_stream_fail(reckless->cmd,
@@ -205,6 +203,7 @@ static struct command_result *reckless_fail(struct reckless *reckless,
205203
static void reckless_conn_finish(struct io_conn *conn,
206204
struct reckless *reckless)
207205
{
206+
io_close(conn);
208207
/* FIXME: avoid EBADFD - leave stdin fd open? */
209208
if (errno && errno != 9)
210209
plugin_log(plugin, LOG_DBG, "err: %s", strerror(errno));
@@ -226,14 +225,13 @@ static void reckless_conn_finish(struct io_conn *conn,
226225
if (p != reckless->pid && reckless->pid) {
227226
plugin_log(plugin, LOG_DBG, "reckless failed to exit, "
228227
"killing now.");
229-
io_close(conn);
230228
kill(reckless->pid, SIGKILL);
231229
reckless_fail(reckless, "reckless process hung");
232230
/* Reckless process exited and with normal status? */
233231
} else if (WIFEXITED(status) && !WEXITSTATUS(status)) {
234232
plugin_log(plugin, LOG_DBG,
235233
"Reckless subprocess complete");
236-
reckless_result(conn, reckless);
234+
reckless_result(reckless);
237235
/* Don't try to process json if python raised an error. */
238236
} else {
239237
plugin_log(plugin, LOG_DBG, "%s", reckless->stderrbuf);
@@ -251,7 +249,6 @@ static void reckless_conn_finish(struct io_conn *conn,
251249
"The reckless subprocess has failed.");
252250
}
253251
}
254-
io_close(conn);
255252
tal_free(reckless);
256253
}
257254

0 commit comments

Comments
 (0)