Skip to content

Commit

Permalink
Moved Mutex Unlock before pages visit
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksasiriski committed Jul 31, 2023
1 parent 00a7c69 commit 6e256b1
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/engines/google/google.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,18 @@ func setResult(result *structures.Result, relay *structures.Relay, options *stru
log.Trace().Msgf("Got Result %v: %v", result.Title, result.URL)

relay.Mutex.Lock()
defer relay.Mutex.Unlock()

mapRes, exists := relay.ResultMap[result.URL]

if !exists {
relay.ResultMap[result.URL] = result

if options.VisitPages {
pagesCol.Visit(result.URL)
}
} else if len(mapRes.Description) < len(result.Description) {
mapRes.Description = result.Description
}
relay.Mutex.Unlock()

if !exists && options.VisitPages {
pagesCol.Visit(result.URL)
}
}

func setResultResponse(link string, response *colly.Response, relay *structures.Relay) {
Expand Down

0 comments on commit 6e256b1

Please sign in to comment.