summaryrefslogtreecommitdiff
path: root/lib9p/srv.c
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-07 05:25:53 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-12 21:37:47 -0600
commitb44901b57bd12a1b152903771d38a4211d9bb5ad (patch)
tree857f8ba20c8fe4a15f5e630baf51cff6f635aaa2 /lib9p/srv.c
parent7741ed43f5bc0be9473a281d050c6fbdbc6aea81 (diff)
lib9p: srv: Tidy lib9p_srv_read
Diffstat (limited to 'lib9p/srv.c')
-rw-r--r--lib9p/srv.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib9p/srv.c b/lib9p/srv.c
index 0a561d3..1e52609 100644
--- a/lib9p/srv.c
+++ b/lib9p/srv.c
@@ -282,19 +282,18 @@ void lib9p_srv_read(struct lib9p_srv *srv, lo_interface net_stream_conn _conn) {
.initialized = false,
};
for (;;) {
- nextmsg:
/* Read the message. */
size_t done = 0;
uint8_t buf[7];
if (read_exactly(conn.fd, buf, 4, &done))
- goto close;
+ break;
size_t goal = uint32le_decode(buf);
if (goal < 7) {
nonrespond_errorf("T-message is impossibly small");
- goto close;
+ break;
}
if (read_exactly(conn.fd, buf, 7, &done))
- goto close;
+ break;
struct _lib9p_srv_req req = {
.parent_sess = &sess,
.tag = uint16le_decode(&buf[5]),
@@ -313,14 +312,14 @@ void lib9p_srv_read(struct lib9p_srv *srv, lo_interface net_stream_conn _conn) {
goal,
sess.max_msg_size);
respond_error(&req);
- goto nextmsg;
+ continue;
}
req.net_bytes = malloc(goal);
assert(req.net_bytes);
memcpy(req.net_bytes, buf, done);
if (read_exactly(conn.fd, req.net_bytes, goal, &done)) {
free(req.net_bytes);
- goto close;
+ break;
}
/* Handle the message... */
@@ -331,7 +330,6 @@ void lib9p_srv_read(struct lib9p_srv *srv, lo_interface net_stream_conn _conn) {
/* ...but usually in another coroutine. */
_lib9p_srv_reqch_send_req(&srv->_reqch, &req);
}
- close:
if (sess.reqs.len == 0)
io_close(conn.fd);
else {