1
0
mirror of https://github.com/gilbertchen/duplicacy synced 2025-12-15 07:43:21 +00:00

Remove debugging code not needed for the push request.

This commit is contained in:
TheBestPessimist
2017-10-01 12:06:19 +03:00
parent 0dd138e16f
commit bd39302eee

View File

@@ -18,8 +18,6 @@ import (
"sync"
"time"
"runtime"
"golang.org/x/net/context"
"golang.org/x/oauth2"
"google.golang.org/api/drive/v3"
@@ -109,34 +107,12 @@ func (storage *GCDStorage) shouldRetry(threadIndex int, err error) (bool, error)
storage.backoffsRetries[threadIndex] += 1
}
delay := storage.backoffs[threadIndex]*rand.Float64() + storage.backoffs[threadIndex]*rand.Float64()
if storage.backoffs[threadIndex] >= LIMIT_BACKOFF_TIME {
callerChain := findCallerChain()
LOG_INFO("GCD_RETRY", "Thread: %3d. Message:%s. Retrying after %6.2f seconds. Current backoff: %6.2f. Number of retries: %2d. caller chain: %s", threadIndex, message, delay, storage.backoffs[threadIndex], storage.backoffsRetries[threadIndex], callerChain)
}
LOG_DEBUG("GCD_RETRY", "Thread: %3d. Message: %s. Retrying after %6.2f seconds. Current backoff: %6.2f. Number of retries: %2d.", threadIndex, message, delay, storage.backoffs[threadIndex], storage.backoffsRetries[threadIndex])
time.Sleep(time.Duration(delay * float64(time.Second)))
return true, nil
}
func findCallerChain() string {
callerStack := ""
pc := make([]uintptr, 15)
n := runtime.Callers(1, pc)
frames := runtime.CallersFrames(pc[:n])
for {
frame, more := frames.Next()
if strings.Contains(frame.File, "runtime/") {
break
}
callerStack += "->" + frame.Function
if !more {
break
}
}
return callerStack
}
/*
logic for said calculus is here: https://stackoverflow.com/questions/1527803/generating-random-whole-numbers-in-javascript-in-a-specific-range
chose 0.1*thread number as a minimum sleep time