Skip to content

0.29.3: what a readiness enquiry held is delivered with the rest, by recv as by read; handles retired before they are closed - #91

Merged
Sunrisepeak merged 1 commit into
mainfrom
fix/0.29.3-held-byte
Nov 12, 2026
Merged

Sunrisepeak merged 1 commit into
mainfrom
fix/0.29.3-held-byte

Conversation

@Sunrisepeak

Copy link
Copy Markdown
Member

Fixes #52.

poll and select answer for a connection by taking one byte and holding it. read returned that byte with whatever else had arrived (a read bounded by now); recv, recvfrom and recvmsg returned the byte alone, so a program that polls before each recv took a stream one byte per wakeup.

  • The delivery is one function: okm_take_ahead places the held byte and reads what else has arrived behind it; do_read and okm_sock_recv both call it, so a call that delivers the byte cannot leave the rest out. Datagram sockets are unchanged (the enquiry holds a whole message).
  • examples/net sends a thousand bytes in one call and counts: through poll and recv, and through poll and recvmsg with two buffers. Before: the first recv returned 1 byte, 1000 calls for 1000 bytes, and recvmsg returned 1. After: 1000 in one call.
  • The implementations are named at ^0.26.1 (Linux), ^0.23.1 (macOS) and ^0.22.1 (Windows), which retire a handle before closing it (kal_net_close closes the descriptor before retiring the handle, so a file opened at the same moment gets a stale handle and its I/O goes to descriptor 0 openkal-linux#53): above this C library a file opened while another thread closed a socket had its reads and writes reach descriptor 0. openkal-windows moves from 0.21 to 0.22 with it.

…recv as by read; handles retired before they are closed
@Sunrisepeak
Sunrisepeak merged commit 945f9aa into main Nov 12, 2026
21 of 22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

recv right after poll returns one byte on a connected socket (openkal-musl 0.20.1)

1 participant