diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-12-18 23:51:47 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-12-19 00:00:33 +0900 |
| commit | ce06b7b66386f592df26ca089b470cc5b40ecd39 (patch) | |
| tree | a01446a02bb544fc4adb2265e338c935fe7510b0 /internal/pipewire/pipewire_test.go | |
| parent | 08bdc68f3a00fadad3eb196d08f328722bc7504c (diff) | |
internal/pipewire: inform conn of blocking intent
The interface does not expose underlying kernel notification mechanisms. This change removes the need to poll in situations were the next call might block.
This is made cumbersome by the SyscallConn interface left over from a previous implementation, it will be replaced in a later commit as the current implementation does not make use of any net.Conn methods other than Close.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pipewire/pipewire_test.go')
| -rw-r--r-- | internal/pipewire/pipewire_test.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/internal/pipewire/pipewire_test.go b/internal/pipewire/pipewire_test.go index 0b65b86b..9305e7ec 100644 --- a/internal/pipewire/pipewire_test.go +++ b/internal/pipewire/pipewire_test.go @@ -6,6 +6,7 @@ import ( "strconv" . "syscall" "testing" + "time" "hakurei.app/container/stub" "hakurei.app/internal/pipewire" @@ -715,6 +716,18 @@ type stubUnixConn struct { current int } +func (conn *stubUnixConn) MightBlock(timeout time.Duration) { + if timeout != 5*time.Second { + panic("unexpected timeout " + timeout.String()) + } + if conn.current == 0 || + (conn.samples[conn.current-1].nr == SYS_RECVMSG && conn.samples[conn.current-1].errno == EAGAIN && conn.samples[conn.current].nr == SYS_SENDMSG) || + (conn.samples[conn.current-1].nr == SYS_SENDMSG && conn.samples[conn.current].nr == SYS_RECVMSG) { + return + } + panic("unexpected blocking hint before sample " + strconv.Itoa(conn.current)) +} + // nextSample returns the current sample and increments the counter. func (conn *stubUnixConn) nextSample(nr uintptr) (sample *stubUnixConnSample, wantOOB []byte, err error) { sample = &conn.samples[conn.current] |
