Skip to content

Commit

Permalink
Enhancement | Add trace logs for packet size (#2522)
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Engel committed May 24, 2024
1 parent b178ba5 commit b7c4007
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2740,6 +2740,9 @@ private bool TryProcessEnvChange(int tokenLength, TdsParserStateObject stateObj,
// to MARS initialization!
int packetSize = int.Parse(env._newValue, NumberStyles.Integer, CultureInfo.InvariantCulture);

SqlClientEventSource.Log.TryTraceEvent("{0}.{1} | Info | Server sent env packet size change of {2}, ClientConnectionID {3}",
nameof(TdsParser), nameof(TryProcessEnvChange), packetSize, _connHandler._clientConnectionId);

if (_physicalStateObj.SetPacketSize(packetSize))
{
// If packet size changed, we need to release our SNIPackets since
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3182,6 +3182,9 @@ private bool TryProcessEnvChange(int tokenLength, TdsParserStateObject stateObj,
// to MARS initialization!
int packetSize = int.Parse(env._newValue, NumberStyles.Integer, CultureInfo.InvariantCulture);

SqlClientEventSource.Log.TryTraceEvent("{0}.{1} | Info | Server sent env packet size change of {2}, ClientConnectionID {3}",
nameof(TdsParser), nameof(TryProcessEnvChange), packetSize, _connHandler._clientConnectionId);

if (_physicalStateObj.SetPacketSize(packetSize))
{
// If packet size changed, we need to release our SNIPackets since
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,9 @@ internal bool SetPacketSize(int size)
(_outBytesUsed == _outputHeaderLen && _outputPacketNumber == 1),
"SetPacketSize called with data in the buffer!");

SqlClientEventSource.Log.TryTraceEvent("{0}.{1} | Info | State Object Id {2}, Setting packet size to {3}",
nameof(TdsParserStateObject), nameof(SetPacketSize), _objectID, size);

if (_inBuff == null || _inBuff.Length != size)
{ // We only check _inBuff, since two buffers should be consistent.
// Allocate or re-allocate _inBuff.
Expand Down

0 comments on commit b7c4007

Please sign in to comment.