shithub: neoventi

Download patch

ref: a4f141bd3a1af74816c85f8266ee1125437698eb
parent: cda9ba6f76bfe31f24670280f0feea69b3804507
author: Noam Preil <noam@pixelhero.dev>
date: Fri Jun 28 16:04:20 EDT 2024

index: report bucket lookup error to client

--- a/disk.c
+++ b/disk.c
@@ -73,8 +73,10 @@
 	}
 	if(s_sect->bucketmagic && U32GET(buf + 2) != s_sect->bucketmagic)
 		sysfatal("index is corrupt: invalid bucket magic: sect %ux, buck %ux", s_sect->bucketmagic, U32GET(buf + 2));
-	if(!bucketlookup(buf, score, &entry))
-		sysfatal("entry not found in bucket");
+	if(!bucketlookup(buf, score, &entry)){
+		werrstr("entry not found in bucket");
+		return 0;
+	}
 	addr->offset = U64GET((buf + 6 + (entry * IEntrySize) + 26));
 	addr->size = U16GET((buf + 6 + (entry * IEntrySize) + 34));
 	addr->blocks = buf[6 + (entry*IEntrySize) + 37];
@@ -156,7 +158,10 @@
 {
 	u16int size = addr.blocks<<ABlockLog;
 	uchar buf[0x10000];
-	vtreadarena(addr.s_arena, addr.offset, buf, size);
+	if(!vtreadarena(addr.s_arena, addr.offset, buf, size)){
+		werrstr("arena read failed: %r");
+		return 0;
+	}
 	size = U16GET(buf+7);
 	if(buf[29] == 2){
 		if(unwhack(dst, size, buf+38, U16GET(buf+5)) != size){
--- a/server.c
+++ b/server.c
@@ -86,8 +86,9 @@
 {
 	VtAddress addr;
 	if(!vtreadlookup((u8int*)buf + 4, &addr))
-		sysfatal("todo graceful read errors");
-	readclump((uchar*)buf+4, addr);
+		vterr(conn, buf, "read error: %r");
+	if(!readclump((uchar*)buf+4, addr))
+		vterr(conn, buf, "clump read failed: %");
 	vtsend(conn, buf, addr.size+2, VtRread, 0);
 }