ref: 53f749d02ad4780eab161b856d49b84f54909bc1
parent: e8ed35d914bdf4445a4e915ca361f6eb26bbd611
author: Noam Preil <noam@pixelhero.dev>
date: Sun Dec 24 12:13:00 EST 2023
report errors as coming from neoventi
--- a/server.c
+++ b/server.c
@@ -3,7 +3,6 @@
#include <bio.h>
#include "neoventi.h"
-
// Handles an error on `conn` handling client request `tbuf`
// Only the tag must be preserved in the buffer
static void
@@ -14,13 +13,13 @@
va_start(args, msg);
msg = vsmprint(msg, args);
werrstr(msg);
+ free(msg);
va_end(args);
if(tbuf != nil){
- len = strlen(msg);
+ len = snprint(tbuf+6, 0x10000, "neoventi: %r");
tbuf[2] = VtRerror;
tbuf[4] = len >> 8;
tbuf[5] = len & 0xFF;
- memcpy(tbuf + 6, msg, len);
len += 4;
tbuf[0] = len >> 8;
tbuf[1] = len & 0xFF;
@@ -27,7 +26,6 @@
if(write(conn.fd, tbuf, len+2) != len+2)
fprint(2, "failed to report error: %r");
}
- free(msg);
longjmp(conn.bounce, 1);
}