Skip to content

Commit

Permalink
More logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
ptabor committed Dec 8, 2024
1 parent 41b2e19 commit 47beca2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions http/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,29 +339,33 @@ func (h *Handler) connectAllInternal(iface string, waitSec string) error {
ctx := context.Background()
devices := h.discoverDnsEntries(ctx, iface, waitSec)
apps := make(chan *application.App, len(devices)+1)
//
g, ctx := errgroup.WithContext(ctx)
for _, device := range devices {
g.Go(func() error {
log.Printf("Connecting to %s:%d (%s)", device.Addr, device.Port, device.DeviceName)
app, err := h.connectInternal(device.Addr, device.Port, device.DeviceName)
if err != nil {
log.Printf("Connection to %s:%d (%s) failed: %v", device.Addr, device.Port, device.DeviceName, err)
return err
}
log.Printf("Connected to %s:%d (%s)", device.Addr, device.Port, device.DeviceName)
apps <- &app
return nil
})
}
err := g.Wait()
log.Printf("Post wait status: %v", err)
close(apps)

// Even if we cannot connect to some of the devices, we still update the map for remaining devices.
uuidMap := map[string]application.App{}
for app := range apps {
info, err := (*app).Info()
if err != nil {
return err
log.Printf("Skipping device %v", app)
} else {
uuidMap[strings.ReplaceAll(info.SsdpUdn, "-", "")] = *app
}
uuidMap[strings.ReplaceAll(info.SsdpUdn, "-", "")] = *app
}

h.mu.Lock()
Expand Down

0 comments on commit 47beca2

Please sign in to comment.