MCPcopy
hub / github.com/lxc/incus / runDNSServer

Method runDNSServer

internal/server/dns/server.go:69–142  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

67}
68
69func (s *Server) runDNSServer() {
70 shouldRun := false
71 address := ""
72
73 for cmd := range s.cmd {
74 switch cmd.cmd {
75 case serverCmdStart:
76 if shouldRun {
77 continue
78 }
79
80 shouldRun = true
81 address = cmd.address
82 s.mu.Lock()
83 err := s.start(cmd.address)
84 if err != nil {
85 // Run in new goroutine to avoid deadlock.
86 go s.handleErr(err)
87 }
88
89 s.mu.Unlock()
90 case serverCmdRestart:
91 s.mu.Lock()
92 // don't start if the server shouldn't run or is already running (s.address is set when the server starts)
93 if !shouldRun || s.address != "" {
94 s.mu.Unlock()
95 continue
96 }
97
98 err := s.start(address)
99 if err != nil {
100 // Run in new goroutine to avoid deadlock.
101 go s.handleErr(err)
102 }
103
104 s.mu.Unlock()
105 case serverCmdStop:
106 shouldRun = false
107 s.mu.Lock()
108 s.stop()
109 s.mu.Unlock()
110 case serverCmdReconfigure:
111 s.mu.Lock()
112 s.stop()
113
114 if cmd.address == "" {
115 shouldRun = false
116 } else {
117 shouldRun = true
118 address = cmd.address
119 err := s.start(cmd.address)
120 if err != nil {
121 // Run in new goroutine to avoid deadlock.
122 go s.handleErr(err)
123 }
124 }
125
126 s.mu.Unlock()

Callers 1

StartMethod · 0.95

Implementers 3

ProtocolSimpleStreamsclient/simplestreams.go
ProtocolIncusclient/incus.go
ProtocolOCIclient/oci.go

Calls 4

startMethod · 0.95
handleErrMethod · 0.95
stopMethod · 0.95
ErrorfFunction · 0.92

Tested by

no test coverage detected