From 8cc87f8c1f25c9d3fec00561237891650a91b47a Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Wed, 2 Apr 2025 17:34:54 -0600 Subject: lib9p: srv: Log messages that are received and sent --- lib9p/srv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib9p/srv.c') diff --git a/lib9p/srv.c b/lib9p/srv.c index 2723207..bfeb06f 100644 --- a/lib9p/srv.c +++ b/lib9p/srv.c @@ -199,6 +199,7 @@ static void respond_error(struct _lib9p_srv_req *req) { LIB9P_TYP_Rerror, &host, &net); + infof("< %v", lo_box_lib9p_msg_Rerror_as_fmt_formatter(&host)); r = write_Rmsg(req, &net); if (r < 0) nonrespond_errorf("write: %s", net_strerror(-r)); @@ -419,11 +420,12 @@ static void handle_message(struct _lib9p_srv_req *ctx) { ssize_t host_size = lib9p_Tmsg_validate(&ctx->ctx.basectx, ctx->net_bytes); if (host_size < 0) goto write; - host_req = malloc(host_size); + host_req = calloc(1, host_size); assert(host_req); enum lib9p_msg_type typ; lib9p_Tmsg_unmarshal(&ctx->ctx.basectx, ctx->net_bytes, &typ, host_req); + infof("> %v", lo_box_lib9p_msg_as_fmt_formatter(&ctx->ctx.basectx, typ, host_req)); /* Handle it. */ tmessage_handlers[typ](ctx, (void *)host_req, (void *)host_resp); @@ -437,6 +439,7 @@ static void handle_message(struct _lib9p_srv_req *ctx) { typ+1, host_resp, &net_resp)) goto write; + infof("< %v", lo_box_lib9p_msg_as_fmt_formatter(&ctx->ctx.basectx, typ+1, &host_resp)); write_Rmsg(ctx, &net_resp); } if (host_req) -- cgit v1.2.3-2-g168b