atproto relay implementation in zig zlay.waow.tech

fix: use File.readAll directly for /proc metrics, thread headers through admin GET handlers

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+6 -4
+6 -4
src/broadcaster.zig
··· 626 if (std.fs.openFileAbsolute("/proc/self/statm", .{})) |f| { 627 defer f.close(); 628 var statm_buf: [256]u8 = undefined; 629 - if (f.reader().readAll(&statm_buf)) |n| { 630 const line = statm_buf[0..n]; 631 var iter = std.mem.splitScalar(u8, line, ' '); 632 _ = iter.next(); // skip total pages ··· 639 , .{pages * 4096}) catch {}; 640 } else |_| {} 641 } 642 - } else |_| {} 643 } else |_| {} 644 645 // thread count from /proc/self/status 646 if (std.fs.openFileAbsolute("/proc/self/status", .{})) |f| { 647 defer f.close(); 648 var status_buf: [4096]u8 = undefined; 649 - if (f.reader().readAll(&status_buf)) |n| { 650 const content = status_buf[0..n]; 651 if (std.mem.indexOf(u8, content, "Threads:")) |pos| { 652 const rest = content[pos + "Threads:".len ..]; ··· 660 , .{threads}) catch {}; 661 } else |_| {} 662 } 663 - } else |_| {} 664 } else |_| {} 665 } 666
··· 626 if (std.fs.openFileAbsolute("/proc/self/statm", .{})) |f| { 627 defer f.close(); 628 var statm_buf: [256]u8 = undefined; 629 + const n = f.readAll(&statm_buf) catch 0; 630 + if (n > 0) { 631 const line = statm_buf[0..n]; 632 var iter = std.mem.splitScalar(u8, line, ' '); 633 _ = iter.next(); // skip total pages ··· 640 , .{pages * 4096}) catch {}; 641 } else |_| {} 642 } 643 + } 644 } else |_| {} 645 646 // thread count from /proc/self/status 647 if (std.fs.openFileAbsolute("/proc/self/status", .{})) |f| { 648 defer f.close(); 649 var status_buf: [4096]u8 = undefined; 650 + const n = f.readAll(&status_buf) catch 0; 651 + if (n > 0) { 652 const content = status_buf[0..n]; 653 if (std.mem.indexOf(u8, content, "Threads:")) |pos| { 654 const rest = content[pos + "Threads:".len ..]; ··· 662 , .{threads}) catch {}; 663 } else |_| {} 664 } 665 + } 666 } else |_| {} 667 } 668