Skip to content

Commit

Permalink
ctlsocksrv: move Listen() call here
Browse files Browse the repository at this point in the history
Prep for solving #776
  • Loading branch information
rfjakob committed Sep 2, 2024
1 parent f665be1 commit 40abf96
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 9 additions & 0 deletions internal/ctlsocksrv/ctlsock_listen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package ctlsocksrv

import (
"net"
)

func Listen(path string) (net.Listener, error) {
return net.Listen("unix", path)
}
8 changes: 3 additions & 5 deletions mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"log"
"log/syslog"
"math"
"net"
"os"
"os/exec"
"os/signal"
Expand Down Expand Up @@ -91,16 +90,15 @@ func doMount(args *argContainer) {
// We must use an absolute path because we cd to / when daemonizing.
// This messes up the delete-on-close logic in the unix socket object.
args.ctlsock, _ = filepath.Abs(args.ctlsock)
var sock net.Listener
sock, err = net.Listen("unix", args.ctlsock)

args._ctlsockFd, err = ctlsocksrv.Listen(args.ctlsock)
if err != nil {
tlog.Fatal.Printf("ctlsock: %v", err)
os.Exit(exitcodes.CtlSock)
}
args._ctlsockFd = sock
// Close also deletes the socket file
defer func() {
err = sock.Close()
err = args._ctlsockFd.Close()
if err != nil {
tlog.Warn.Printf("ctlsock close: %v", err)
}
Expand Down

0 comments on commit 40abf96

Please sign in to comment.