shithub: mycel

Download patch

ref: ace2ae8862cf3b124d21815a24484c3137ae77c1
parent: 9f6a5105c5f00becacda853aaba00603020f941d
author: Philip Silva <philip.silva@protonmail.com>
date: Sun Oct 24 13:43:40 EDT 2021

Fix site change on unix

--- a/js/js.go
+++ b/js/js.go
@@ -92,6 +92,7 @@
 
 func Stop() {
 	log.Infof("Stop gojafs")
+	hangup()
 	if cancel != nil {
 		cancel()
 	}
--- a/js/js_plan9.go
+++ b/js/js_plan9.go
@@ -5,6 +5,8 @@
 	"os"
 )
 
+func hangup() {}
+
 func callGojaCtl() (rwc io.ReadWriteCloser, err error) {
 	return os.OpenFile("/mnt/goja/ctl", os.O_RDWR, 0600)
 }
--- a/js/js_unix.go
+++ b/js/js_unix.go
@@ -11,7 +11,10 @@
 	"os/user"
 )
 
-var fsys *client.Fsys
+var (
+	conn *client.Conn
+	fsys *client.Fsys
+)
 
 func dial() (err error) {
 	log.Infof("Init...")
@@ -29,6 +32,16 @@
 		log.Fatalf("attach: %v", err)
 	}
 	return
+}
+
+func hangup() {
+	if fsys != nil {
+		fsys = nil
+	}
+	if conn != nil {
+		conn.Close()
+		conn = nil
+	}
 }
 
 func callGojaCtl() (rwc io.ReadWriteCloser, err error) {