mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
parent
b89a1cd482
commit
9216981262
@ -115,7 +115,7 @@ func (l *lockServer) Lock(args *LockArgs, reply *bool) error {
|
|||||||
}
|
}
|
||||||
_, *reply = l.lockMap[args.Name]
|
_, *reply = l.lockMap[args.Name]
|
||||||
if !*reply { // No locks held on the given name, so claim write lock
|
if !*reply { // No locks held on the given name, so claim write lock
|
||||||
l.lockMap[args.Name] = []lockRequesterInfo{lockRequesterInfo{writer: true, node: args.Node, rpcPath: args.RPCPath, uid: args.UID, timestamp: time.Now(), timeLastCheck: time.Now()}}
|
l.lockMap[args.Name] = []lockRequesterInfo{{writer: true, node: args.Node, rpcPath: args.RPCPath, uid: args.UID, timestamp: time.Now(), timeLastCheck: time.Now()}}
|
||||||
}
|
}
|
||||||
*reply = !*reply // Negate *reply to return true when lock is granted or false otherwise
|
*reply = !*reply // Negate *reply to return true when lock is granted or false otherwise
|
||||||
return nil
|
return nil
|
||||||
@ -152,7 +152,7 @@ func (l *lockServer) RLock(args *LockArgs, reply *bool) error {
|
|||||||
var lri []lockRequesterInfo
|
var lri []lockRequesterInfo
|
||||||
lri, *reply = l.lockMap[args.Name]
|
lri, *reply = l.lockMap[args.Name]
|
||||||
if !*reply { // No locks held on the given name, so claim (first) read lock
|
if !*reply { // No locks held on the given name, so claim (first) read lock
|
||||||
l.lockMap[args.Name] = []lockRequesterInfo{lockRequesterInfo{writer: false, node: args.Node, rpcPath: args.RPCPath, uid: args.UID, timestamp: time.Now(), timeLastCheck: time.Now()}}
|
l.lockMap[args.Name] = []lockRequesterInfo{{writer: false, node: args.Node, rpcPath: args.RPCPath, uid: args.UID, timestamp: time.Now(), timeLastCheck: time.Now()}}
|
||||||
*reply = true
|
*reply = true
|
||||||
} else {
|
} else {
|
||||||
if *reply = !isWriteLock(lri); *reply { // Unless there is a write lock
|
if *reply = !isWriteLock(lri); *reply { // Unless there is a write lock
|
||||||
|
@ -24,6 +24,31 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Tests caclculating disk count.
|
||||||
|
func TestDiskCount(t *testing.T) {
|
||||||
|
testCases := []struct {
|
||||||
|
disks []StorageAPI
|
||||||
|
diskCount int
|
||||||
|
}{
|
||||||
|
// Test case - 1
|
||||||
|
{
|
||||||
|
disks: []StorageAPI{&posix{}, &posix{}, &posix{}, &posix{}},
|
||||||
|
diskCount: 4,
|
||||||
|
},
|
||||||
|
// Test case - 2
|
||||||
|
{
|
||||||
|
disks: []StorageAPI{nil, &posix{}, &posix{}, &posix{}},
|
||||||
|
diskCount: 3,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for i, testCase := range testCases {
|
||||||
|
cdiskCount := diskCount(testCase.disks)
|
||||||
|
if cdiskCount != testCase.diskCount {
|
||||||
|
t.Errorf("Test %d: Expected %d, got %d", i+1, testCase.diskCount, cdiskCount)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Test for reduceErrs, reduceErr reduces collection
|
// Test for reduceErrs, reduceErr reduces collection
|
||||||
// of errors into a single maximal error with in the list.
|
// of errors into a single maximal error with in the list.
|
||||||
func TestReduceErrs(t *testing.T) {
|
func TestReduceErrs(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user