szn

Bug 227 — Socket write loop pegs CPU on 0-byte writes

227. Socket write loop pegs CPU on 0-byte writes

File: src/server/dispatch.zig:98–116 Severity: CRITICAL Status: ✅ FIXED

The loops writing hdr_remaining and body_remaining to the file descriptor check n < 0 but do not check if n == 0. If std.c.write returns 0, the loop spins infinitely without advancing the remaining slice pointer.

Impact: 100% CPU utilization (infinite spin) on disconnected or unwriteable client sockets.

Fix: Add if (n == 0) return error.ConnectionClosed; immediately after the n < 0 check.