From e51c0a77c845a58b24a87dd4d5a9b5f4c4cc9df7 Mon Sep 17 00:00:00 2001 From: hiddenMedic <124312252+hiddenMedic@users.noreply.github.com> Date: Mon, 31 Jul 2023 14:04:05 +0200 Subject: [PATCH] removed readlock on copied map item --- src/rank/rank.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/rank/rank.go b/src/rank/rank.go index 33d4f7f6..aa3624ae 100644 --- a/src/rank/rank.go +++ b/src/rank/rank.go @@ -7,16 +7,13 @@ import ( "github.com/tminaorg/brzaguza/src/structures" ) -// only one call for setResultResponse for a page will ever be performed, so there will never be a read and a write to result.Response at the same time -// thus not locking relay.ResultMap[result.URL] in this function, because the result parameter is a copy is safe. It may, however, read memory that the map sees, -// at the same time that the map is being written to, while this should be fine in this use-case, go may throw an error. // TLDR: you must mutex.Lock when changing *rankAddr, you probably dont need to mutex.RLock() when reading result // (in reality even *rankAddr shouldnt need a lock, but go would definately complain about simultanious read/write because of it) func SetRank(result *structures.Result, rankAddr *int, mutex *sync.RWMutex) { - mutex.RLock() - reqUrl := result.Response.Request.URL.String() //dummy code - mutex.RUnlock() + //mutex.RLock() + reqUrl := result.Response.Request.URL.String() //dummy code, if error here, uncomment lock + //mutex.RUnlock() if reqUrl != result.URL { //dummy code log.Trace().Msg("Request URL not same as result.URL \\/")