summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2014-01-09 18:58:19 (GMT)
committer Denys Vlasenko <vda.linux@googlemail.com>2014-01-09 18:58:19 (GMT)
commit3ea93e853e44fd7e227688cb96f5f847817862c0 (patch)
tree36c9360a7171012d5767ff5b23430ac1f9359e1d
parent89deb22f9745e145fdbb4fbe985cfa9e20e90024 (diff)
downloadbusybox-3ea93e853e44fd7e227688cb96f5f847817862c0.tar.gz
busybox-3ea93e853e44fd7e227688cb96f5f847817862c0.tar.bz2
networking: explain isrv_run() API
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/isrv.h27
1 files changed, 26 insertions, 1 deletions
diff --git a/networking/isrv.h b/networking/isrv.h
index 4c7e01d..a42fd41 100644
--- a/networking/isrv.h
+++ b/networking/isrv.h
@@ -23,7 +23,32 @@ int isrv_register_fd(isrv_state_t *state, int peer, int fd);
void isrv_close_fd(isrv_state_t *state, int fd);
int isrv_register_peer(isrv_state_t *state, void *param);
-/* driver */
+/* Driver:
+ *
+ * Select on listen_fd for <linger_timeout> (or forever if 0).
+ *
+ * If we time out and we have no peers, exit.
+ * If we have peers, call do_timeout(peer_param),
+ * if it returns !0, peer is removed.
+ *
+ * If listen_fd is active, accept new connection ("peer"),
+ * call new_peer() on it, and if it returns 1,
+ * and add it to fds to select on.
+ * Now, select will wait for <timeout>, not <linger_timeout>
+ * (as long as we we have more than zero clients).
+ *
+ * If a peer's fd is active, we call do_rd() on it if read
+ * mask bit was set,
+ * and then do_wr() if write mask bit was also set.
+ * If either returns !0, peer is removed.
+ * Reaching this place also resets timeout counter for this peer.
+ *
+ * Note that peer must indicate that he wants to be selected
+ * for read and/or write using isrv_want_rd()/isrv_want_wr()
+ * [can be called in new_peer() or in do_rd()/do_wr()].
+ * If it never wants to be selected for write, do_wr()
+ * will never be called (can be NULL).
+ */
void isrv_run(
int listen_fd,
int (*new_peer)(isrv_state_t *state, int fd),