Skip to content

Commit

Permalink
Fix excess error message during writes
Browse files Browse the repository at this point in the history
Fixes juanfont#2290

Signed-off-by: Kristoffer Dalby <[email protected]>
  • Loading branch information
kradalby committed Dec 15, 2024
1 parent f541003 commit ae2becb
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions hscontrol/dns/extrarecords.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ func (e *ExtraRecordsMan) updateRecords() {
return
}

// If there are no records, ignore the update.
if records == nil {
return
}

e.mu.Lock()
defer e.mu.Unlock()

Expand Down Expand Up @@ -143,6 +148,12 @@ func readExtraRecordsFromPath(path string) ([]tailcfg.DNSRecord, [32]byte, error
return nil, [32]byte{}, fmt.Errorf("reading path: %s, err: %w", path, err)
}

// If the read was triggered too fast, and the file is not complete, ignore the update
// if the file is empty. A consecutive update will be triggered when the file is complete.
if len(b) == 0 {
return nil, [32]byte{}, nil
}

var records []tailcfg.DNSRecord
err = json.Unmarshal(b, &records)
if err != nil {
Expand Down

0 comments on commit ae2becb

Please sign in to comment.