Skip to content

Commit

Permalink
Change overwrite to affect any "locked in"/completed state
Browse files Browse the repository at this point in the history
  • Loading branch information
adreed-msft committed Sep 20, 2022
1 parent e109305 commit b360bc2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 5 additions & 0 deletions common/fe-ste-models.go
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,11 @@ var ETransferStatus = TransferStatus(0)

type TransferStatus int32 // Must be 32-bit for atomic operations; negative #s represent a specific failure code

func (t TransferStatus) StatusLocked() bool { // Is an overwrite necessary to change tx status?
// Any kind of failure, or success is considered "locked in".
return t <= ETransferStatus.Failed() || t == ETransferStatus.Started()
}

// Transfer is ready to transfer and not started transferring yet
func (TransferStatus) NotStarted() TransferStatus { return TransferStatus(0) }

Expand Down
5 changes: 2 additions & 3 deletions ste/JobPartPlan.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,8 @@ func (jppt *JobPartPlanTransfer) SetTransferStatus(status common.TransferStatus,
if !overWrite {
common.AtomicMorphInt32((*int32)(&jppt.atomicTransferStatus),
func(startVal int32) (val int32, morphResult interface{}) {
// start value < 0 means that transfer status is already a failed value.
// If current transfer status has already failed value, then it will not be changed.
return common.Iffint32(startVal < 0, startVal, int32(status)), nil
// If current transfer status has some completed value, then it will not be changed.
return common.Iffint32(common.TransferStatus(startVal).StatusLocked(), startVal, int32(status)), nil
})
} else {
(&jppt.atomicTransferStatus).AtomicStore(status)
Expand Down

0 comments on commit b360bc2

Please sign in to comment.