Repository navigation
Socket api across read 2 - #73
Conversation
readSocket() read at most 1023 bytes per call and left message reassembly to a FIXME. The socket is a SOCK_STREAM and carries no message boundaries, so any reply longer than the buffer -- or merely split across two reads by the kernel -- was parsed as two independent messages. Both halves then failed to parse, the original reply was lost, and the waiting open() sat out its full backoff. Worse, the effect is self-sustaining: once the stream desynchronises every subsequent message on the connection is misparsed, so a single long reply broke hydration until restart. A V2/HYDRATE_FILE_RESULT carrying a path plus a free-form arguments.error string clears 1 KB without trying. processSocketInput() now drains the socket into a persistent buffer, dispatches only complete newline terminated messages, and keeps the remainder for the next read. handleReceivedMsg() correspondingly handles a single message and no longer splits on newlines itself, which also retires its trailing-empty-fragment case. The buffer is bounded so a peer that never sends a newline cannot grow it without limit.
There was a problem hiding this comment.
🟡 Changes recommended
Socket shutdown handling can flood logs, and the receive-size limit can be bypassed.
1 open finding
What changed in this PR
Adds buffered socket input handling so fragmented and batched newline-delimited messages are processed correctly.
Changes:
- Accumulates partial reads and dispatches complete messages.
- Adds receive-buffer limits and socket error handling.
| File | Description |
|---|---|
src/openvfsfuse/socketthread.h |
Declares buffered input processing and storage. |
src/openvfsfuse/socketthread.cpp |
Implements stream buffering, framing, and dispatch. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
TheOneRing
left a comment
There was a problem hiding this comment.
Nitpick, rest looks fine now.
| // stop reading in all other error conditions | ||
| contRead = false; | ||
|
|
||
| if (errno != EAGAIN |
There was a problem hiding this comment.
I'm not that used to raw unix sockets could you add a comment that mentions that EAGAIN just mean, "nothing to read here, please go on" .
And would a while(true) { break; } loop be more conventional?
There was a problem hiding this comment.
No, please let me keep that state var 🙏

Successor of #71 with applied review feedback.