MCPcopy
hub / github.com/burke/zeus / Start

Function Start

go/clienthandler/clienthandler.go:20–57  ·  view source on GitHub ↗

Start boosts the process tree.

(tree *processtree.ProcessTree, done chan bool)

Source from the content-addressed store, hash-verified

18
19// Start boosts the process tree.
20func Start(tree *processtree.ProcessTree, done chan bool) chan bool {
21 quit := make(chan bool)
22 go func() {
23 path, _ := filepath.Abs(unixsocket.ZeusSockName())
24 os.Remove(path) // Clean up stale socket from previous session
25 addr, err := net.ResolveUnixAddr("unix", path)
26 if err != nil {
27 zerror.Error("Can't open socket.")
28 }
29 listener, err := net.ListenUnix("unix", addr)
30 if err != nil {
31 zerror.ErrorCantCreateListener()
32 }
33
34 connections := make(chan *unixsocket.Usock)
35 go func() {
36 for {
37 conn, err := listener.AcceptUnix()
38 if err != nil {
39 return // listener was closed
40 }
41 connections <- unixsocket.New(conn)
42 }
43 }()
44
45 for {
46 select {
47 case <-quit:
48 listener.Close()
49 done <- true
50 return
51 case conn := <-connections:
52 go handleClientConnection(tree, conn)
53 }
54 }
55 }()
56 return quit
57}
58
59// see docs/client_master_handshake.md
60func handleClientConnection(tree *processtree.ProcessTree, usock *unixsocket.Usock) {

Callers 1

runSessionFunction · 0.92

Calls 6

ZeusSockNameFunction · 0.92
ErrorFunction · 0.92
ErrorCantCreateListenerFunction · 0.92
NewFunction · 0.92
handleClientConnectionFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…