internal/wayland: clean up pathname socket
All checks were successful
Test / Hakurei (push) Successful in 10m33s
Test / Create distribution (push) Successful in 35s
Test / Sandbox (push) Successful in 1m32s
Test / Hpkg (push) Successful in 3m24s
Test / Sandbox (race detector) (push) Successful in 4m19s
Test / Hakurei (race detector) (push) Successful in 5m12s
Test / Flake checks (push) Successful in 1m36s
All checks were successful
Test / Hakurei (push) Successful in 10m33s
Test / Create distribution (push) Successful in 35s
Test / Sandbox (push) Successful in 1m32s
Test / Hpkg (push) Successful in 3m24s
Test / Sandbox (race detector) (push) Successful in 4m19s
Test / Hakurei (race detector) (push) Successful in 5m12s
Test / Flake checks (push) Successful in 1m36s
This is cleaner than cleaning up in internal/system as it covers the failure paths. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -14,7 +14,9 @@ package wayland
|
||||
import "C"
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"strings"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -83,6 +85,9 @@ const (
|
||||
RHostSocket Res = C.HAKUREI_WAYLAND_HOST_SOCKET
|
||||
// RHostConnect is returned if connect failed for host server. Returned by [New].
|
||||
RHostConnect Res = C.HAKUREI_WAYLAND_HOST_CONNECT
|
||||
|
||||
// RCleanup is returned if cleanup fails. Returned by [SecurityContext.Close].
|
||||
RCleanup Res = C.HAKUREI_WAYLAND_CLEANUP
|
||||
)
|
||||
|
||||
func (e *Error) Unwrap() error { return e.Errno }
|
||||
@@ -124,6 +129,19 @@ func (e *Error) Error() string {
|
||||
case RHostConnect:
|
||||
return e.withPrefix("cannot connect to " + e.Host)
|
||||
|
||||
case RCleanup:
|
||||
var pathError *os.PathError
|
||||
if errors.As(e.Errno, &pathError) && pathError != nil {
|
||||
return pathError.Error()
|
||||
}
|
||||
|
||||
var errno syscall.Errno
|
||||
if errors.As(e.Errno, &errno) && errno != 0 {
|
||||
return "cannot close wayland close_fd pipe: " + errno.Error()
|
||||
}
|
||||
|
||||
return e.withPrefix("cannot hang up wayland security_context")
|
||||
|
||||
default:
|
||||
return e.withPrefix("impossible outcome") /* not reached */
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user