call activate() when the socket is ready, i.e. when it's
connected.
call shutdown() when the socket is closed, in the destructor.
when fr_bio_shutdown() is called manually, it also mangles the
shutdown callback, so that the fd bio doesn't call it again in
its destructor.
/*
* Call user shutdown before the bio shutdown.
+ *
+ * Then set it to NULL so that it doesn't get called again on talloc cleanups.
*/
if (my->cb.shutdown && ((rcode = my->cb.shutdown(last)) < 0)) return rcode;
+ my->cb.shutdown = NULL;
+
last = fr_bio_prev(last);
} while (last);
fr_assert(!fr_bio_prev(&my->bio));
fr_assert(!fr_bio_next(&my->bio));
+ if (my->cb.shutdown) my->cb.shutdown(&my->bio);
+
return fr_bio_fd_close(&my->bio);
}
my->info.read_blocked = false;
my->info.write_blocked = false;
+ /*
+ * Tell the caller that the socket is ready for application data.
+ */
+ if (my->cb.activate) my->cb.activate(&my->bio);
+
return 0;
}
return fr_bio_error(IO);
}
- my->info.state = FR_BIO_FD_STATE_OPEN;
-
/*
* The socket is connected, so initialize the normal IO handlers.
*/