1 Commits

Author SHA1 Message Date
42700ee3be release: 0.3.2
All checks were successful
Test / Create distribution (push) Successful in 40s
Test / Sandbox (push) Successful in 2m40s
Test / Sandbox (race detector) (push) Successful in 4m41s
Test / Hpkg (push) Successful in 5m18s
Test / Hakurei (race detector) (push) Successful in 6m56s
Test / Hakurei (push) Successful in 8m20s
Test / Flake checks (push) Successful in 1m45s
Signed-off-by: Ophestra <cat@gensokyo.uk>
2025-12-08 23:12:05 +09:00
3 changed files with 20 additions and 25 deletions

View File

@@ -380,9 +380,6 @@ func initEntrypoint(k syscallDispatcher, msg message.Msg) {
err error
wpid = -2
wstatus WaitStatus
// whether initial process has started
started bool
)
// keep going until no child process is left
@@ -409,10 +406,6 @@ func initEntrypoint(k syscallDispatcher, msg message.Msg) {
}
}
if !started {
started = initialProcessStarted.Load()
}
err = EINTR
for errors.Is(err, EINTR) {
wpid, err = k.wait4(-1, &wstatus, 0, nil)
@@ -421,7 +414,7 @@ func initEntrypoint(k syscallDispatcher, msg message.Msg) {
if !errors.Is(err, ECHILD) {
k.printf(msg, "unexpected wait4 response: %v", err)
} else if !started {
} else if !initialProcessStarted.Load() {
// initial process has not yet been reached and all daemons
// terminated or none were started in the first place
time.Sleep(500 * time.Microsecond)

View File

@@ -63,7 +63,7 @@ type Context struct {
generation Long
// Pending file descriptors to be sent with the next message.
pendingFiles []int
// File count already kept track of in [Header].
// File count kept track of in [Header].
headerFiles int
// Files from the server. This is discarded on every Roundtrip so eventProxy
// implementations must make sure to close them to avoid leaking fds.
@@ -271,20 +271,16 @@ func (ctx *Context) recvmsg(remaining []byte) (payload []byte, err error) {
n, oobn, recvflags, err = ctx.conn.Recvmsg(ctx.iovecBuf[len(remaining):], ctx.oobBuf[:], recvmsgFlags)
if oob := ctx.oobBuf[:oobn]; len(oob) > 0 {
var oobErr error
var scm []syscall.SocketControlMessage
if scm, oobErr = syscall.ParseSocketControlMessage(oob); oobErr != nil {
if scm, err = syscall.ParseSocketControlMessage(oob); err != nil {
ctx.closeReceivedFiles()
err = oobErr
return
}
var fds []int
for i := range scm {
if fds, oobErr = syscall.ParseUnixRights(&scm[i]); oobErr != nil {
if fds, err = syscall.ParseUnixRights(&scm[i]); err != nil {
ctx.closeReceivedFiles()
err = oobErr
return
}
ctx.receivedFiles = append(ctx.receivedFiles, fds...)
@@ -314,7 +310,7 @@ func (ctx *Context) recvmsg(remaining []byte) (payload []byte, err error) {
err = syscall.EPIPE // not wrapped as it did not come from the syscall
}
if n > 0 {
payload = ctx.iovecBuf[:len(remaining)+n]
payload = ctx.iovecBuf[:n]
}
return
}
@@ -585,9 +581,6 @@ func (ctx *Context) roundtrip() (err error) {
if err = ctx.sendmsg(ctx.buf, ctx.pendingFiles...); err != nil {
return
}
ctx.buf = ctx.buf[:0]
ctx.pendingFiles = ctx.pendingFiles[:0]
ctx.headerFiles = 0
defer func() {
var danglingFiles DanglingFilesError
@@ -664,6 +657,10 @@ func (ctx *Context) consume(receiveRemaining []byte) (remaining []byte, err erro
return
}()
ctx.buf = ctx.buf[:0]
ctx.pendingFiles = ctx.pendingFiles[:0]
ctx.headerFiles = 0
if remaining, err = ctx.recvmsg(receiveRemaining); err != nil {
return
}
@@ -677,14 +674,20 @@ func (ctx *Context) consume(receiveRemaining []byte) (remaining []byte, err erro
if err = header.UnmarshalBinary(remaining[:SizeHeader]); err != nil {
return
}
// remote sequence sometimes do not start with 0
if ctx.remoteSequence == 0 {
ctx.remoteSequence = header.Sequence
}
if header.Sequence != ctx.remoteSequence {
return remaining, UnexpectedSequenceError(header.Sequence)
}
ctx.remoteSequence++
if len(remaining) < int(SizeHeader+header.Size) {
return
}
ctx.remoteSequence++
proxy, ok := ctx.proxy[header.ID]
if !ok {
@@ -820,7 +823,8 @@ func connectName(name string, manager bool) (conn *net.UnixConn, err error) {
}
// ConnectName connects to a PipeWire remote by name.
func ConnectName(name string, manager bool, props SPADict) (ctx *Context, err error) {
func ConnectName(name string, manager bool) (ctx *Context, err error) {
var props SPADict
if manager {
props = append(props, SPADictItem{Key: PW_KEY_REMOTE_INTENTION, Value: "manager"})
}
@@ -846,6 +850,4 @@ func ConnectName(name string, manager bool, props SPADict) (ctx *Context, err er
}
// Connect connects to the PipeWire remote.
func Connect(manager bool, props SPADict) (ctx *Context, err error) {
return ConnectName("", manager, props)
}
func Connect(manager bool) (ctx *Context, err error) { return ConnectName("", manager) }

View File

@@ -89,7 +89,7 @@ func (k direct) waylandNew(displayPath, bindPath *check.Absolute, appID, instanc
return wayland.New(displayPath, bindPath, appID, instanceID)
}
func (k direct) pipewireConnect() (*pipewire.Context, error) { return pipewire.Connect(true, nil) }
func (k direct) pipewireConnect() (*pipewire.Context, error) { return pipewire.Connect(true) }
func (k direct) xcbChangeHosts(mode xcb.HostMode, family xcb.Family, address string) error {
return xcb.ChangeHosts(mode, family, address)