Link: order the streams of an attachment by bind sequence - #358
Merged
Merged
Conversation
The serve peer assigns each bound stream a sequence under its tracking lock, before it answers Bound, and passes it to the service handler. A stream bound later gets a larger sequence however late its handler runs, so a service can fence a stream's successor by bind order. Handlers that need no order ignore it.
TestBindSequence opens two streams of one attachment, lets the later one's handler report first, reconnects the serve peer and opens a third; the sequences the handlers saw must increase strictly from above zero. The ServiceHandler comment and the Link guide define bind order as the order of assignment under the serve peer's tracking lock, which concurrent Bound and Opened replies need not follow, and scope the sequence to one Serve call: it survives reconnects and increases strictly, with gaps.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link protocol change, split out of the File protocol fixes (plan row 6a, L1c) so that it gets its own review.
What changes
sandboxlink.ServiceHandler.Servenow also receives a bind sequence:func(ctx, Bind, seq uint64, Stream).track's lock, before it answersBound. A stream of an attachment that binds later therefore gets a larger sequence, however late its handler runs.docs/sandbox-link-protocol.md§ "Implement a serve peer" states that order. A service may rely on it to fence the succession of an attachment's streams.Why
The File protocol's stream succession fence admits one stream per attachment at a time. Without this change, its order would come from when each handler reaches the File server, which can differ from bind order. This PR only adds the sequence; the File protocol PR that follows uses it.
Callers
sandboxio, the File and Process handlers accept and ignore it, so the File protocol is unchanged at this commit.Checks
go build ./...go vet ./internal/sandboxlink/... ./apps/sandboxio/... ./apps/daemon/...go test -race -count=1 ./internal/sandboxlink/... ./apps/sandboxio/... ./apps/daemon/internal/gateway/GOOS=darwinandGOOS=windowsbuilds of./internal/sandboxlink/... ./apps/daemon/...Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.