diff --git a/go/nix/nixstore/remotestore.go b/go/nix/nixstore/remotestore.go index 85bed91f86..c5a69b0eb2 100644 --- a/go/nix/nixstore/remotestore.go +++ b/go/nix/nixstore/remotestore.go @@ -7,6 +7,7 @@ import ( "net" "path" "strings" + "sync" "hg.lukegb.com/lukegb/depot/go/nix/nar/narinfo" "hg.lukegb.com/lukegb/depot/go/nix/nixwire" @@ -26,9 +27,14 @@ type Daemon struct { conn net.Conn w *nixwire.Serializer r *nixwire.Deserializer + mu sync.Mutex + err error } func (d *Daemon) NARInfo(storePath string) (*narinfo.NarInfo, error) { + d.mu.Lock() + defer d.mu.Unlock() + if _, err := d.w.WriteUint64(WopQueryPathInfo); err != nil { return nil, fmt.Errorf("writing worker op WopQueryPathInfo: %w", err) } @@ -104,6 +110,9 @@ func (d *Daemon) NARInfo(storePath string) (*narinfo.NarInfo, error) { } func (d *Daemon) Close() error { + d.mu.Lock() + defer d.mu.Unlock() + return d.conn.Close() }