tests: Add test for diskCount. (#2717)

Fixes #2312
This commit is contained in:
Harshavardhana
2016-09-16 13:44:52 -07:00
committed by GitHub
parent b89a1cd482
commit 9216981262
2 changed files with 27 additions and 2 deletions

View File

@@ -115,7 +115,7 @@ func (l *lockServer) Lock(args *LockArgs, reply *bool) error {
}
_, *reply = l.lockMap[args.Name]
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
return nil
@@ -152,7 +152,7 @@ func (l *lockServer) RLock(args *LockArgs, reply *bool) error {
var lri []lockRequesterInfo
lri, *reply = l.lockMap[args.Name]
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
} else {
if *reply = !isWriteLock(lri); *reply { // Unless there is a write lock