summaryrefslogtreecommitdiff
path: root/lib9p/include
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-06 03:28:09 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-12 21:37:47 -0600
commit7741ed43f5bc0be9473a281d050c6fbdbc6aea81 (patch)
treee4532cb4643bbf450bffc818d0194922b6b93b93 /lib9p/include
parent52674d0483e3754b039857be1d11798859c5bcef (diff)
lib9p: Rename the server coroutine functions, pull out the read func
Diffstat (limited to 'lib9p/include')
-rw-r--r--lib9p/include/lib9p/srv.h58
1 files changed, 41 insertions, 17 deletions
diff --git a/lib9p/include/lib9p/srv.h b/lib9p/include/lib9p/srv.h
index 85fc6bd..7f2711c 100644
--- a/lib9p/include/lib9p/srv.h
+++ b/lib9p/include/lib9p/srv.h
@@ -149,32 +149,56 @@ struct lib9p_srv {
};
/**
- * In an infinite loop, accept a connection and read messages from it until
- * close; dispatching requests to a pool of lib9p_srv_write_cr() coroutines
- * with the same `srv`.
+ * In a loop loop, accept a connection call lib9p_srv_read() on it.
+ * If LO_CALL(listener, accept) fails, then the function returns.
*
- * Will just close the connection if a T-message has a size[4] <7.
+ * When the last lib9p_srv_accept_and_read_loop() instance for a given
+ * `srv` returns, it will signal all lib9p_srv_worker_loop() calls to
+ * return.
+ *
+ * @param srv: The server configuration and state; has an associated
+ * pool of lib9p_srv_worker_loop() coroutines.
*
- * @param srv: The server configuration and state; has an associated pool of
- * lib9p_srv_write_cr() coroutines.
* @param listener: The listener object to accept connections from.
+ */
+void lib9p_srv_accept_and_read_loop(struct lib9p_srv *srv, lo_interface net_stream_listener listener);
+
+/**
+ * You should probably not call this directly; you should probably use
+ * lib9p_srv_accept_and_read_loop().
+ *
+ * Given an already-established stream connection (i.e. a TCP
+ * connection), service that connection; return once the connection is
+ * closed. Requests are dispatched to a pool of
+ * lib9p_srv_worker_loop() coroutines with the same `srv`.
*
- * @errno LINUX_EMSGSIZE T-message has size[4] bigger than max_msg_size
- * @errno LINUX_EDOM Tversion specified an impossibly small max_msg_size
+ * Will just close the connection if a T-message has a size[4] <7.
+ *
+ * @param srv: The server configuration and state; has an associated
+ * pool of lib9p_srv_worker_loop() coroutines.
+ *
+ * @param conn: The listener object to accept connections from.
+ *
+ * Errors that this function itself may send to clients:
+ *
+ * @errno LINUX_EMSGSIZE T-message has size[4] bigger than max_msg_size
+ * @errno LINUX_EDOM Tversion specified an impossibly small max_msg_size
* @errno LINUX_EOPNOTSUPP T-message has an R-message type, or an unrecognized T-message type
- * @errno LINUX_EBADMSG T-message has wrong size[4] for its content, or has invalid UTF-8
- * @errno LINUX_ERANGE R-message does not fit into max_msg_size
+ * @errno LINUX_EBADMSG T-message has wrong size[4] for its content, or has invalid UTF-8
+ * @errno LINUX_ERANGE R-message does not fit into max_msg_size
*/
-[[noreturn]] void lib9p_srv_read_cr(struct lib9p_srv *srv, lo_interface net_stream_listener listener);
+void lib9p_srv_read(struct lib9p_srv *srv, lo_interface net_stream_conn conn);
+
+
/**
- * Service requests to the `struct lib9p_srv *srv` argument that have been
- * read by lib9p_srv_read_cr().
+ * In a loop, service requests to the `struct lib9p_srv *srv` argument
+ * that have been read by lib9p_srv_accept_and_read_loop() /
+ * lib9p_srv_read(). A "NULL" request causes the function to return.
*
- * @param struct lib9p_srv *srv: The server configuration and state; has an
- * associated pool of lib9p_srv_read_cr()
- * coroutines.
+ * @param srv: The server configuration and state; has an associated
+ * pool of lib9p_srv_accept_and_read_loop() coroutines.
*/
-COROUTINE lib9p_srv_write_cr(void *_srv);
+void lib9p_srv_worker_loop(struct lib9p_srv *srv);
#endif /* _LIB9P_SRV_H_ */