Skip to content

Socket api across read 2 - #73

Merged
dragotin merged 3 commits into
mainfrom
socketApiAcrossRead2
Oct 12, 2026
Merged

dragotin merged 3 commits into
mainfrom
socketApiAcrossRead2

Conversation

@dragotin

@dragotin dragotin commented Oct 9, 2026

Copy link
Copy Markdown
Member

Successor of #71 with applied review feedback.

toxicphreAK and others added 2 commits October 9, 2026 17:46
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.
@dragotin
dragotin requested review from TheOneRing and a balanced review from Copilot October 9, 2026 16:05
@dragotin dragotin mentioned this pull request Oct 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Comment thread src/openvfsfuse/socketthread.cpp Resolved

@TheOneRing TheOneRing left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick, rest looks fine now.

// stop reading in all other error conditions
contRead = false;

if (errno != EAGAIN

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, please let me keep that state var 🙏

@dragotin
dragotin requested a review from TheOneRing October 12, 2026 13:26
@dragotin
dragotin merged commit 4c2317b into main Oct 12, 2026
1 check passed
@dragotin
dragotin deleted the socketApiAcrossRead2 branch October 12, 2026 14:52
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.

4 participants