mirror of https://github.com/minio/minio.git
				
				
				
			return correct context errors for locking operations (#14569)
if a context is canceled do not need to return a timeout error instead, return the appropriate error for context canceled.
This commit is contained in:
		
							parent
							
								
									b20ecc7b54
								
							
						
					
					
						commit
						7bd9f821dd
					
				|  | @ -170,6 +170,10 @@ func (di *distLockInstance) GetLock(ctx context.Context, timeout *dynamicTimeout | |||
| 	}) { | ||||
| 		timeout.LogFailure() | ||||
| 		cancel() | ||||
| 		switch err := newCtx.Err(); err { | ||||
| 		case context.Canceled: | ||||
| 			return LockContext{ctx: ctx, cancel: func() {}}, err | ||||
| 		} | ||||
| 		return LockContext{ctx: ctx, cancel: func() {}}, OperationTimedOut{} | ||||
| 	} | ||||
| 	timeout.LogSuccess(UTCNow().Sub(start)) | ||||
|  | @ -195,6 +199,10 @@ func (di *distLockInstance) GetRLock(ctx context.Context, timeout *dynamicTimeou | |||
| 	}) { | ||||
| 		timeout.LogFailure() | ||||
| 		cancel() | ||||
| 		switch err := newCtx.Err(); err { | ||||
| 		case context.Canceled: | ||||
| 			return LockContext{ctx: ctx, cancel: func() {}}, err | ||||
| 		} | ||||
| 		return LockContext{ctx: ctx, cancel: func() {}}, OperationTimedOut{} | ||||
| 	} | ||||
| 	timeout.LogSuccess(UTCNow().Sub(start)) | ||||
|  | @ -247,6 +255,10 @@ func (li *localLockInstance) GetLock(ctx context.Context, timeout *dynamicTimeou | |||
| 					li.ns.unlock(li.volume, li.paths[si], readLock) | ||||
| 				} | ||||
| 			} | ||||
| 			switch err := ctx.Err(); err { | ||||
| 			case context.Canceled: | ||||
| 				return LockContext{}, err | ||||
| 			} | ||||
| 			return LockContext{}, OperationTimedOut{} | ||||
| 		} | ||||
| 		success[i] = 1 | ||||
|  | @ -280,6 +292,10 @@ func (li *localLockInstance) GetRLock(ctx context.Context, timeout *dynamicTimeo | |||
| 					li.ns.unlock(li.volume, li.paths[si], readLock) | ||||
| 				} | ||||
| 			} | ||||
| 			switch err := ctx.Err(); err { | ||||
| 			case context.Canceled: | ||||
| 				return LockContext{}, err | ||||
| 			} | ||||
| 			return LockContext{}, OperationTimedOut{} | ||||
| 		} | ||||
| 		success[i] = 1 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue