void *io_loop_return;
struct io_plan io_conn_freed;
+static bool io_extended_errors;
struct io_listener *io_new_listener_(const tal_t *ctx, int fd,
struct io_plan *(*init)(struct io_conn *,
/* And leave unset .*/
return &conn->plan[IO_IN];
}
-
+
bool io_flush_sync(struct io_conn *conn)
{
struct io_plan *plan = &conn->plan[IO_OUT];
io_fd_block(io_conn_fd(conn), false);
return ok;
}
+
+void io_set_extended_errors(bool state)
+{
+ io_extended_errors = state;
+}
+
+bool io_get_extended_errors(void)
+{
+ return io_extended_errors;
+}
* (tal'ocated off @ctx) and pass that to init(). Note that if there is
* an error on this file descriptor, it will be freed.
*
+ * Note: if the accept fails (usually due to EMFILE), init() will be called
+ * wth
* Returns NULL on error (and sets errno).
*
* Example:
*/
const void *io_have_fd(int fd, bool *listener);
+/**
+ * io_set_extended_errors - enable callbacks for errors.
+ * @state: true or false.
+ *
+ * Defaults false for compatibility. See io_new_conn for what this changes.
+ */
+void io_set_extended_errors(bool state);
+bool io_get_extended_errors(void);
+
#endif /* CCAN_IO_H */
{
int fd = accept(l->fd.fd, NULL, NULL);
- /* FIXME: What to do here? */
- if (fd < 0)
+ if (fd < 0) {
+ /* If they've enabled it, this is how we tell them */
+ if (io_get_extended_errors())
+ l->init(NULL, l->arg);
return;
-
+ }
io_new_conn(l->ctx, fd, l->init, l->arg);
}