Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Unified Diff: impl/memory/taskqueue_data.go

Issue 2547793002: impl/memory: Use random int as auto generated task name in Task Queues. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | impl/memory/taskqueue_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/memory/taskqueue_data.go
diff --git a/impl/memory/taskqueue_data.go b/impl/memory/taskqueue_data.go
index 5ecd3ee12ed91c4662ca9d7ac7f3a42e58fd0ecb..bf21954d1437be37615cb71f4dce05ebf3607996 100644
--- a/impl/memory/taskqueue_data.go
+++ b/impl/memory/taskqueue_data.go
@@ -63,13 +63,9 @@ func newSortedQueue(name string, isPullQueue bool) *sortedQueue {
// All sortedQueue methods are assumed to be called under taskQueueData lock.
func (q *sortedQueue) genTaskName(c context.Context) string {
- const validTaskChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_"
for {
- buf := [500]byte{}
- for i := 0; i < 500; i++ {
- buf[i] = validTaskChars[mathrand.Intn(c, len(validTaskChars))]
- }
- name := string(buf[:])
+ // Real Task Queue service seems to be using random ints too.
+ name := fmt.Sprintf("%d", mathrand.Int63(c))
_, ok1 := q.tasks[name]
_, ok2 := q.archived[name]
if !ok1 && !ok2 {
« no previous file with comments | « no previous file | impl/memory/taskqueue_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698