Skip to content

Commit

Permalink
move ResetSnapshotState to shared
Browse files Browse the repository at this point in the history
  • Loading branch information
Wraith2 committed Sep 13, 2023
1 parent ac5c4f6 commit 58bb963
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3168,45 +3168,6 @@ internal void Snap(TdsParserStateObject state)
PushBuffer(_stateObj._inBuff, _stateObj._inBytesRead);
}

internal void ResetSnapshotState()
{
// go back to the beginning
_snapshotInBuffCurrent = 0;

Replay();

_stateObj._inBytesUsed = _snapshotInBytesUsed;
_stateObj._inBytesPacket = _snapshotInBytesPacket;

_stateObj._messageStatus = _snapshotMessageStatus;
_stateObj._nullBitmapInfo = _snapshotNullBitmapInfo;
_stateObj._cleanupMetaData = _snapshotCleanupMetaData;
_stateObj._cleanupAltMetaDataSetArray = _snapshotCleanupAltMetaDataSetArray;

// Make sure to go through the appropriate increment/decrement methods if changing the OpenResult flag
if (!_stateObj.HasOpenResult && ((_state & SnapshottedStateFlags.OpenResult) == SnapshottedStateFlags.OpenResult))
{
_stateObj.IncrementAndObtainOpenResultCount(_stateObj._executedUnderTransaction);
}
else if (_stateObj.HasOpenResult && ((_state & SnapshottedStateFlags.OpenResult) != SnapshottedStateFlags.OpenResult))
{
_stateObj.DecrementOpenResultCount();
}
_stateObj._snapshottedState = _state;

// Reset partially read state (these only need to be maintained if doing async without snapshot)
_stateObj._bTmpRead = 0;
_stateObj._partialHeaderBytesRead = 0;

// reset plp state
_stateObj._longlen = _plpData?.SnapshotLongLen ?? 0;
_stateObj._longlenleft = _plpData?.SnapshotLongLenLeft ?? 0;

_stateObj._snapshotReplay = true;

_stateObj.AssertValidState();
}

internal void Clear()
{
PacketData packet = _snapshotInBuffList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3298,45 +3298,6 @@ internal void Snap(TdsParserStateObject state)
PushBuffer(_stateObj._inBuff, _stateObj._inBytesRead);
}

internal void ResetSnapshotState()
{
// go back to the beginning
_snapshotInBuffCurrent = 0;

Replay();

_stateObj._inBytesUsed = _snapshotInBytesUsed;
_stateObj._inBytesPacket = _snapshotInBytesPacket;
_stateObj._messageStatus = _snapshotMessageStatus;
_stateObj._nullBitmapInfo = _snapshotNullBitmapInfo;
_stateObj._cleanupMetaData = _snapshotCleanupMetaData;
_stateObj._cleanupAltMetaDataSetArray = _snapshotCleanupAltMetaDataSetArray;

// Make sure to go through the appropriate increment/decrement methods if changing HasOpenResult
if (!_stateObj.HasOpenResult && ((_state & SnapshottedStateFlags.OpenResult) == SnapshottedStateFlags.OpenResult))
{
_stateObj.IncrementAndObtainOpenResultCount(_stateObj._executedUnderTransaction);
}
else if (_stateObj.HasOpenResult && ((_state & SnapshottedStateFlags.OpenResult) != SnapshottedStateFlags.OpenResult))
{
_stateObj.DecrementOpenResultCount();
}
//else _stateObj._hasOpenResult is already == _snapshotHasOpenResult
_stateObj._snapshottedState = _state;

// Reset partially read state (these only need to be maintained if doing async without snapshot)
_stateObj._bTmpRead = 0;
_stateObj._partialHeaderBytesRead = 0;

// reset plp state
_stateObj._longlen = _plpData?.SnapshotLongLen ?? 0;
_stateObj._longlenleft = _plpData?.SnapshotLongLenLeft ?? 0;

_stateObj._snapshotReplay = true;

_stateObj.AssertValidState();
}

internal void Clear()
{
_snapshotInBuffs.Clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,45 @@ internal void CloneCleanupAltMetaDataSetArray()
}
}

internal void ResetSnapshotState()
{
// go back to the beginning
_snapshotInBuffCurrent = 0;

Replay();

_stateObj._inBytesUsed = _snapshotInBytesUsed;
_stateObj._inBytesPacket = _snapshotInBytesPacket;
_stateObj._messageStatus = _snapshotMessageStatus;
_stateObj._nullBitmapInfo = _snapshotNullBitmapInfo;
_stateObj._cleanupMetaData = _snapshotCleanupMetaData;
_stateObj._cleanupAltMetaDataSetArray = _snapshotCleanupAltMetaDataSetArray;

// Make sure to go through the appropriate increment/decrement methods if changing HasOpenResult
if (!_stateObj.HasOpenResult && ((_state & SnapshottedStateFlags.OpenResult) == SnapshottedStateFlags.OpenResult))
{
_stateObj.IncrementAndObtainOpenResultCount(_stateObj._executedUnderTransaction);
}
else if (_stateObj.HasOpenResult && ((_state & SnapshottedStateFlags.OpenResult) != SnapshottedStateFlags.OpenResult))
{
_stateObj.DecrementOpenResultCount();
}
//else _stateObj._hasOpenResult is already == _snapshotHasOpenResult
_stateObj._snapshottedState = _state;

// Reset partially read state (these only need to be maintained if doing async without snapshot)
_stateObj._bTmpRead = 0;
_stateObj._partialHeaderBytesRead = 0;

// reset plp state
_stateObj._longlen = _plpData?.SnapshotLongLen ?? 0;
_stateObj._longlenleft = _plpData?.SnapshotLongLenLeft ?? 0;

_stateObj._snapshotReplay = true;

_stateObj.AssertValidState();
}

internal void PrepareReplay()
{
ResetSnapshotState();
Expand Down

0 comments on commit 58bb963

Please sign in to comment.