mirror of
https://github.com/pgsty/minio.git
synced 2026-07-19 20:20:25 +03:00
XL/fs: Initialize export paths supplied on command line (#2020)
Fixes #2013
This commit is contained in:
committed by
Anand Babu (AB) Periasamy
parent
8e8f6f90a4
commit
0e3907072c
@@ -30,7 +30,9 @@ import (
|
||||
"os"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
@@ -61,6 +63,32 @@ const (
|
||||
letterIdxMax = 63 / letterIdxBits // # of letter indices fitting in 63 bits
|
||||
)
|
||||
|
||||
// Random number state.
|
||||
// We generate random temporary file names so that there's a good
|
||||
// chance the file doesn't exist yet.
|
||||
var randN uint32
|
||||
var randmu sync.Mutex
|
||||
|
||||
// reseed - returns a new seed everytime the function is called.
|
||||
func reseed() uint32 {
|
||||
return uint32(time.Now().UnixNano() + int64(os.Getpid()))
|
||||
}
|
||||
|
||||
// nextSuffix - provides a new unique suffix everytime the function is called.
|
||||
func nextSuffix() string {
|
||||
randmu.Lock()
|
||||
r := randN
|
||||
// Initial seed required, generate one.
|
||||
if r == 0 {
|
||||
r = reseed()
|
||||
}
|
||||
// constants from Numerical Recipes
|
||||
r = r*1664525 + 1013904223
|
||||
randN = r
|
||||
randmu.Unlock()
|
||||
return strconv.Itoa(int(1e9 + r%1e9))[1:]
|
||||
}
|
||||
|
||||
// TestServer encapsulates an instantiation of a Minio instance with a temporary backend.
|
||||
// Example usage:
|
||||
// s := StartTestServer(t,"XL")
|
||||
|
||||
Reference in New Issue
Block a user