Skip to content

Commit

Permalink
Fixed map race in concurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
toomore committed May 1, 2021
1 parent a75ed5f commit fee733c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mails/replace.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func filteratags(rg *regexp.Regexp, body *[]byte, cid string) map[string]LinksDa
conn = utils.GetConn()
result = make(map[string]LinksData)
wg sync.WaitGroup
lock = sync.RWMutex{}
)
wg.Add(len(allATags))
for _, v := range allATags {
Expand All @@ -110,11 +111,13 @@ func filteratags(rg *regexp.Regexp, body *[]byte, cid string) map[string]LinksDa
rows.Scan(&linkID)
}
}
lock.Lock()
result[linkID] = LinksData{
Md5h: md5hstr,
LinkID: linkID,
URL: url,
}
lock.Unlock()
wg.Done()
}(v[1])
}
Expand Down

0 comments on commit fee733c

Please sign in to comment.