CONCEPT Cited by 1 source
Socket buffer semantics¶
Socket buffer semantics describe the kernel-managed buffering behavior at each end of a socket connection. Each socket has an inbound (receive) buffer and an outbound (send) buffer, both maintained by the operating system. These buffers decouple the producer's write rate from the consumer's read rate.
Key Properties¶
- Bounded size: Socket buffers have a finite capacity (typically configurable via
SO_SNDBUF/SO_RCVBUF). When the outbound buffer is full, further writes block (blocking I/O) or returnEAGAIN/Poll::Pending(non-blocking/async I/O). - Kernel-managed: The application does not control when bytes leave the buffer โ the kernel transmits when the remote side has space (TCP flow control) or when the receiver reads (Unix sockets).
- Invisible to application logic: A successful
write/sendtomeans bytes are in the kernel buffer, not that they have reached the peer. This distinction is critical for correctness.
The Flush-vs-Shutdown Problem¶
When a process writes data to a socket and then calls shutdown(fd, SHUT_WR), any bytes still in the kernel's outbound buffer are typically delivered (TCP guarantees this via FIN after draining). However, at the application level, if a userspace library (like systems/hyper) maintains its own internal write buffer above the kernel socket buffer, calling shutdown on the socket before flushing the library buffer means that data never enters the kernel at all. It is lost.
This is exactly what happened in the hyper race condition: ~14.8 MB remained in hyper's internal buffer, never reaching the kernel socket buffer, when shutdown was called (Source: sources/2026-06-22-cloudflare-how-we-found-a-bug-in-the-hyper-http-library).
Production Signal¶
Cloudflare observed that the amount of data successfully delivered (~219 KB) matched the kernel socket buffer size โ confirming that only data in the first flush pass (which fit in the socket buffer) was transmitted.
Seen In¶
- sources/2026-06-22-cloudflare-how-we-found-a-bug-in-the-hyper-http-library โ socket buffer filling triggered the hyper race condition