]> git.ozlabs.org Git - ccan/blobdiff - ccan/io/io.h
fdpass: fix complilation on FreeBSD.
[ccan] / ccan / io / io.h
index 1197626f12671a80970b406ce52477bb1c6effed..5d084828b96aa561bbdfd6fe814ea5461f9342cb 100644 (file)
@@ -59,7 +59,7 @@ struct io_conn;
        io_new_conn_((ctx), (fd),                                       \
                     typesafe_cb_preargs(struct io_plan *, void *,      \
                                         (init), (arg),                 \
-                                        struct io_conn *conn),         \
+                                        struct io_conn *),             \
                     (void *)(arg))
 
 struct io_conn *io_new_conn_(const tal_t *ctx, int fd,
@@ -113,6 +113,8 @@ void io_set_finish_(struct io_conn *conn,
  * (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:
@@ -416,7 +418,6 @@ struct io_plan *io_out_always_(struct io_conn *conn,
  *    // Freed if conn closes normally.
  *    timeout = tal(conn, struct timeout_timer);
  *    timeout->conn = conn;
- *    timeout->t = conn;
  *    timer_addrel(&timers, &timeout->t, time_from_sec(5));
  *    return io_sock_shutdown(conn);
  * }
@@ -815,4 +816,22 @@ struct timemono (*io_time_override(struct timemono (*now)(void)))(void);
  */
 int (*io_poll_override(int (*poll)(struct pollfd *fds, nfds_t nfds, int timeout)))(struct pollfd *, nfds_t, int);
 
+/**
+ * io_have_fd - do we own this file descriptor?
+ * @fd: the file descriptor.
+ * @listener: if non-NULL, set to true if it's a listening socket (io_listener).
+ *
+ * Returns NULL if we don't own it, otherwise a struct io_conn * or struct io_listener *.
+ */
+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 */