summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib9p/srv.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib9p/srv.c b/lib9p/srv.c
index 0e58068..9837994 100644
--- a/lib9p/srv.c
+++ b/lib9p/srv.c
@@ -205,12 +205,12 @@ static void respond_error(struct _lib9p_srv_req *req) {
/* read coroutine *************************************************************/
-static bool read_at_least(lo_interface net_stream_conn fd, uint8_t *buf, size_t goal, size_t *done) {
+static bool read_exactly(lo_interface net_stream_conn fd, uint8_t *buf, size_t goal, size_t *done) {
assert(buf);
assert(goal);
assert(done);
while (*done < goal) {
- ssize_t r = LO_CALL(fd, read, &buf[*done], CONFIG_9P_MAX_MSG_SIZE - *done);
+ ssize_t r = LO_CALL(fd, read, &buf[*done], goal - *done);
if (r < 0) {
nonrespond_errorf("read: %s", net_strerror(-r));
return true;
@@ -263,14 +263,14 @@ static void handle_message(struct _lib9p_srv_req *ctx);
nextmsg:
/* Read the message. */
size_t done = 0;
- if (read_at_least(conn.fd, buf, 4, &done))
+ if (read_exactly(conn.fd, buf, 4, &done))
goto close;
size_t goal = uint32le_decode(buf);
if (goal < 7) {
nonrespond_errorf("T-message is impossibly small");
goto close;
}
- if (read_at_least(conn.fd, buf, 7, &done))
+ if (read_exactly(conn.fd, buf, 7, &done))
goto close;
struct _lib9p_srv_req req = {
.parent_sess = &sess,
@@ -292,7 +292,7 @@ static void handle_message(struct _lib9p_srv_req *ctx);
respond_error(&req);
goto nextmsg;
}
- if (read_at_least(conn.fd, buf, goal, &done))
+ if (read_exactly(conn.fd, buf, goal, &done))
goto close;
/* Handle the message... */