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: Rusty Russell <rusty@rustcorp.com.au>
*
* @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
*
* @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)
*
* Example:
* static void finish(struct io_conn *conn, void *unused)
void backend_del_conn(struct io_conn *conn)
{
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);
if (timeout_active(conn))
backend_del_timeout(conn);
io_alloc.free(conn->timeout);
} else
del_fd(&conn->fd);
num_closing--;
} 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);
+ }