ipcutil

package
v0.4.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const MaxMessageSize = 1 << 20

MaxMessageSize is the maximum IPC message size (1MB).

Variables

This section is empty.

Functions

func Read

func Read(r io.Reader) ([]byte, error)

Read reads a length-prefixed IPC message from r.

func Write

func Write(w io.Writer, data []byte) error

Write writes a length-prefixed IPC message to w as a single Write call so the length prefix and payload land atomically on the underlying writer. Callers that share the same writer across goroutines MUST serialize their own Write calls — this function guarantees length+payload framing but does not lock against other goroutines writing to the same w.

PILOT-287 originally tried to enforce caller-side safety with a global sync.Mutex. That serialized every Write across the entire process — including writes on unrelated connections — which on Linux (small pipe buffers) deadlocks the moment any single conn's writer blocks waiting for its reader: every other Write queued on the global mutex stalls behind it, and every reader times out. macOS happened to mask the bug behind larger pipe buffers.

Build the frame in one buffer and hand it to w.Write in one call. At the syscall level this is atomic for small writes (<=PIPE_BUF on Linux, similar elsewhere) — which covers every IPC message the daemon sends. For genuine shared-writer concurrency at the higher layer, wrap the writer with your own mutex.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL