aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2024-10-11 13:20:42 +0200
committerDmitry Vyukov <dvyukov@google.com>2024-10-11 12:12:25 +0000
commitb5c7cf6ea88a9c22e56cf9278989281bb153029d (patch)
tree446376c9d969e061332bd0f6c1a67abffa1f0749
parent6442eb02e371bb42ba68402c9cb7bbabedb81b6d (diff)
tools/syz-reprolist: fix throttling
Throttling must be global, not per goroutine.
-rw-r--r--tools/syz-reprolist/reprolist.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/syz-reprolist/reprolist.go b/tools/syz-reprolist/reprolist.go
index 0c5f9eed1..1881c8465 100644
--- a/tools/syz-reprolist/reprolist.go
+++ b/tools/syz-reprolist/reprolist.go
@@ -364,6 +364,8 @@ func getFullBugList() ([]string, error) {
return fullBugList, nil
}
+var throttler = time.NewTicker(time.Second).C
+
func getJSONBody(url string) ([]byte, error) {
if strings.Contains(url, "?") {
url = url + "&json=1"
@@ -377,7 +379,7 @@ func getJSONBody(url string) ([]byte, error) {
if *flagToken != "" {
req.Header.Add("Authorization", "Bearer "+*flagToken)
} else {
- time.Sleep(time.Second) // tolerate throttling
+ <-throttler // tolerate throttling
}
client := &http.Client{}
res, err := client.Do(req)