Commit 710d42d0 authored by Rusty Russell's avatar Rusty Russell

io: call finish function after fd is actually closed.

This turns out to be the right sequence for pettycoin, which
wants to reap the child in the finish routine.  From that sample
size of 1, this is clearly the Right Thing!
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent ecf907f7
......@@ -39,7 +39,8 @@ struct io_conn *io_new_conn_(int fd, struct io_plan plan);
*
* @finish will be called when an I/O operation fails, or you call
* io_close() on the connection. errno will be set to the value
* after the failed I/O, or at the call to io_close().
* after the failed I/O, or at the call to io_close(). The fd
* will be closed (unless a duplex) before @finish is called.
*
* Example:
* static void finish(struct io_conn *conn, void *unused)
......
......@@ -188,11 +188,6 @@ bool add_duplex(struct io_conn *c)
void backend_del_conn(struct io_conn *conn)
{
if (conn->finish) {
/* Saved by io_close */
errno = conn->plan.u1.s;
conn->finish(conn, conn->finish_arg);
}
if (timeout_active(conn))
backend_del_timeout(conn);
io_alloc.free(conn->timeout);
......@@ -205,6 +200,11 @@ void backend_del_conn(struct io_conn *conn)
} else
del_fd(&conn->fd);
num_closing--;
if (conn->finish) {
/* Saved by io_close */
errno = conn->plan.u1.s;
conn->finish(conn, conn->finish_arg);
}
free_conn(conn);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment