From 32fb137bb2e6eed465e94fd791abfaaab40bf674 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Tue, 2 Dec 2025 21:17:22 +0900 Subject: [PATCH] internal/pipewire: fail on unacknowledged proxies These proxies (with special cases documented in the implementation) are only safe for use after acknowledgement from the server. Signed-off-by: Ophestra --- internal/pipewire/pipewire.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/internal/pipewire/pipewire.go b/internal/pipewire/pipewire.go index b537d39..f1a950c 100644 --- a/internal/pipewire/pipewire.go +++ b/internal/pipewire/pipewire.go @@ -18,6 +18,7 @@ import ( "encoding/binary" "fmt" "io" + "maps" "net" "slices" "strconv" @@ -424,6 +425,14 @@ func (e DanglingFilesError) Error() string { return "received " + strconv.Itoa(len(e)) + " dangling files" } +// An UnacknowledgedProxyError holds newly allocated proxy ids that the server failed +// to acknowledge after an otherwise successful [Context.Roundtrip]. +type UnacknowledgedProxyError []Int + +func (e UnacknowledgedProxyError) Error() string { + return "server did not acknowledge " + strconv.Itoa(len(e)) + " proxies" +} + // roundtripSyncID is the id passed to Context.coreSync during a [Context.Roundtrip]. const roundtripSyncID = 0 @@ -489,6 +498,10 @@ func (ctx *Context) Roundtrip() (err error) { if len(ctx.receivedFiles) < receivedHeaderFiles { return DanglingFilesError(ctx.receivedFiles[len(ctx.receivedFiles)-receivedHeaderFiles:]) } + + if len(ctx.pendingIds) != 0 { + return UnacknowledgedProxyError(slices.Collect(maps.Keys(ctx.pendingIds))) + } return }