summaryrefslogtreecommitdiff
path: root/lib9p/srv.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib9p/srv.c')
-rw-r--r--lib9p/srv.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib9p/srv.c b/lib9p/srv.c
index 5ff083f..836890c 100644
--- a/lib9p/srv.c
+++ b/lib9p/srv.c
@@ -127,7 +127,6 @@ struct _srv_sess {
struct _srv_conn *parent_conn;
enum lib9p_version version;
uint32_t max_msg_size;
- uint32_t rerror_overhead;
/* mutable */
bool initialized;
bool closing;
@@ -190,10 +189,15 @@ static void respond_error(struct _lib9p_srv_req *req) {
struct _srv_sess *sess = req->parent_sess;
+ /* XXX: This assumes that a version's min_msg_size is the
+ * Rerror overhead. That's true for the current
+ * implementation of protogen, but is a sneaky assumption. */
+ uint32_t overhead = lib9p_version_min_msg_size(sess->version);
+
/* Truncate the error-string if necessary to avoid needing to
* return LINUX_ERANGE. */
- if (((uint32_t)host.errstr.len) + sess->rerror_overhead > sess->max_msg_size)
- host.errstr.len = sess->max_msg_size - sess->rerror_overhead;
+ if (((uint32_t)host.errstr.len) + overhead > sess->max_msg_size)
+ host.errstr.len = sess->max_msg_size - overhead;
struct lib9p_Rmsg_send_buf net;
@@ -267,7 +271,6 @@ void lib9p_srv_read(struct lib9p_srv *srv, lo_interface net_stream_conn _conn) {
.parent_conn = &conn,
.version = LIB9P_VER_unknown,
.max_msg_size = CONFIG_9P_SRV_MAX_MSG_SIZE,
- .rerror_overhead = lib9p_version_min_msg_size(LIB9P_VER_unknown),
.initialized = false,
};
for (;;) {
@@ -659,7 +662,6 @@ static void handle_Tversion(struct _lib9p_srv_req *ctx,
/* Replace the old session with the new session. */
ctx->parent_sess->version = version;
ctx->parent_sess->max_msg_size = resp->max_msg_size;
- ctx->parent_sess->rerror_overhead = min_msg_size;
}
static void handle_Tauth(struct _lib9p_srv_req *ctx,