Skip to content

Commit

Permalink
add fc mutx
Browse files Browse the repository at this point in the history
  • Loading branch information
bkleiner committed Oct 7, 2020
1 parent 42c9e39 commit bcccd8c
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions cmd/quic-config/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ type Server struct {
status Status

fl *firmware.FirmwareLoader
fc *controller.Controller
qp *quic.QuicProtocol

fcMu sync.Mutex
fc *controller.Controller
qp *quic.QuicProtocol

fs http.FileSystem

Expand Down Expand Up @@ -90,6 +92,9 @@ func (s *Server) connectController(port string) error {

go s.broadcastQuic(p)

s.fcMu.Lock()
defer s.fcMu.Unlock()

s.fc = c
s.qp = p

Expand All @@ -106,6 +111,9 @@ func (s *Server) controllerStatus() (*Status, error) {
return nil, err
}

s.fcMu.Lock()
defer s.fcMu.Unlock()

status := &Status{
Version: version,
AvailablePorts: ports,
Expand Down Expand Up @@ -136,6 +144,9 @@ func (s *Server) closeController() {
}
s.dfuLoader = nil

s.fcMu.Lock()
defer s.fcMu.Unlock()

if s.fc != nil {
log.Debug("closing fc")
if err := s.qp.Close(); err != nil {
Expand Down

0 comments on commit bcccd8c

Please sign in to comment.