shithub: snarflog

Download patch

ref: 6e608f0e569550ffb3797896f16528c1fb5ba349
parent: c0c014364fd93f3daafec4934bc035f1aec4e773
author: penny <penny@limitedideas.org>
date: Wed Nov 26 07:47:50 EST 2025

use a mutex instead of crashing horribly

--- a/main.go
+++ b/main.go
@@ -4,6 +4,7 @@
 	"fmt"
 	"os"
 	"io"
+	"sync"
 
 	"github.com/knusbaum/go9p/fs"
 	"github.com/knusbaum/go9p"
@@ -15,9 +16,13 @@
 	real *os.File
 	realwrite *os.File
 	snarfStream fs.Stream
+	mu sync.Mutex
 }
 
 func (f *snarfile) Write(fid uint64, offset uint64, data []byte) (uint32, error) {
+	f.mu.Lock()
+	defer f.mu.Unlock()
+
 	f.realwrite.Write(data)
 	_, err := f.snarfStream.Write(data)
 	if err != nil {
--