Skip to content

Commit bc60275

Browse files
committed
Move copying into the caller
1 parent a464782 commit bc60275

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

service/hub.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,7 @@ func (h *connectionsHub) ReportMdnsEntries(entries map[string]MdnsEntry) {
520520
h.muxMdns.Lock()
521521
defer h.muxMdns.Unlock()
522522

523-
mdnsEntries := entries
524-
525-
for ski, entry := range mdnsEntries {
523+
for ski, entry := range entries {
526524
// check if this ski is already connected
527525
if h.isSkiConnected(ski) {
528526
continue

service/mdns.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,9 @@ func (m *mdns) RegisterMdnsSearch(cb MdnsSearch) {
282282
}
283283

284284
// may this is already found
285-
go m.searchDelegate.ReportMdnsEntries(m.entries)
285+
mdnsEntries := m.entries
286+
287+
go m.searchDelegate.ReportMdnsEntries(mdnsEntries)
286288
}
287289

288290
// Remove a callback for found mDNS entries and stop searching if no callbacks are left
@@ -527,6 +529,7 @@ func (m *mdns) processMdnsEntry(elements map[string]string, name, host string, a
527529
}
528530

529531
if m.searchDelegate != nil {
530-
go m.searchDelegate.ReportMdnsEntries(m.entries)
532+
mdnsEntries := m.entries
533+
go m.searchDelegate.ReportMdnsEntries(mdnsEntries)
531534
}
532535
}

0 commit comments

Comments
 (0)