Skip to content

Commit 2e92431

Browse files
committed
fix rebase conflicts
1 parent 7c7e362 commit 2e92431

File tree

2 files changed

+1
-298
lines changed

2 files changed

+1
-298
lines changed

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObject.netcore.cs

Lines changed: 0 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -396,155 +396,6 @@ private void ReadSniError(TdsParserStateObject stateObj, uint error)
396396
private uint GetSniPacket(PacketHandle packet, ref uint dataSize)
397397
{
398398
return SNIPacketGetData(packet, _inBuff, ref dataSize);
399-
if (error != 0)
400-
{
401-
if ((_parser.State == TdsParserState.Closed) || (_parser.State == TdsParserState.Broken))
402-
{
403-
// Do nothing with callback if closed or broken and error not 0 - callback can occur
404-
// after connection has been closed. PROBLEM IN NETLIB - DESIGN FLAW.
405-
return;
406-
}
407-
408-
AddError(_parser.ProcessSNIError(this));
409-
AssertValidState();
410-
}
411-
else
412-
{
413-
uint dataSize = 0;
414-
bool usedPartialPacket = false;
415-
uint getDataError = 0;
416-
417-
if (usePartialPacket && _snapshot == null && _partialPacket != null && _partialPacket.IsComplete)
418-
{
419-
//Debug.Assert(_snapshot == null, "_snapshot must be null when processing partial packet instead of network read");
420-
//Debug.Assert(_partialPacket != null, "_partialPacket must not be null when usePartialPacket is true");
421-
//Debug.Assert(_partialPacket.IsComplete, "_partialPacket.IsComplete must be true to use it in place of a real read");
422-
SetBuffer(_partialPacket.Buffer, 0, _partialPacket.CurrentLength);
423-
ClearPartialPacket();
424-
getDataError = TdsEnums.SNI_SUCCESS;
425-
usedPartialPacket = true;
426-
}
427-
else
428-
{
429-
getDataError = SNIPacketGetData(packet, _inBuff, ref dataSize);
430-
}
431-
432-
if (getDataError == TdsEnums.SNI_SUCCESS)
433-
{
434-
if (_inBuff.Length < dataSize)
435-
{
436-
Debug.Assert(true, "Unexpected dataSize on Read");
437-
throw SQL.InvalidInternalPacketSize(StringsHelper.GetString(Strings.SqlMisc_InvalidArraySizeMessage));
438-
}
439-
440-
if (!usedPartialPacket)
441-
{
442-
_lastSuccessfulIOTimer._value = DateTime.UtcNow.Ticks;
443-
444-
SetBuffer(_inBuff, 0, (int)dataSize);
445-
}
446-
447-
bool recurse;
448-
bool appended = false;
449-
do
450-
{
451-
MultiplexPackets(
452-
_inBuff, _inBytesUsed, _inBytesRead,
453-
_partialPacket,
454-
out int newDataOffset,
455-
out int newDataLength,
456-
out Packet remainderPacket,
457-
out bool consumeInputDirectly,
458-
out bool consumePartialPacket,
459-
out bool remainderPacketProduced,
460-
out recurse
461-
);
462-
bool bufferIsPartialCompleted = false;
463-
464-
// if a partial packet was reconstructed it must be handled first
465-
if (consumePartialPacket)
466-
{
467-
if (_snapshot != null)
468-
{
469-
_snapshot.AppendPacketData(_partialPacket.Buffer, _partialPacket.CurrentLength);
470-
appended = true;
471-
}
472-
else
473-
{
474-
SetBuffer(_partialPacket.Buffer, 0, _partialPacket.CurrentLength);
475-
bufferIsPartialCompleted = true;
476-
}
477-
ClearPartialPacket();
478-
}
479-
480-
// if the remaining data can be processed directly it must be second
481-
if (consumeInputDirectly)
482-
{
483-
// if some data was taken from the new packet adjust the counters
484-
if (dataSize != newDataLength || 0 != newDataOffset)
485-
{
486-
SetBuffer(_inBuff, newDataOffset, newDataLength);
487-
}
488-
489-
if (_snapshot != null)
490-
{
491-
_snapshot.AppendPacketData(_inBuff, _inBytesRead);
492-
appended = true;
493-
}
494-
else
495-
{
496-
SetBuffer(_inBuff, 0, _inBytesRead);
497-
}
498-
}
499-
else
500-
{
501-
// whatever is in the input buffer should not be directly consumed
502-
// and is contained in the partial or remainder packets so make sure
503-
// we don't process it
504-
if (!bufferIsPartialCompleted)
505-
{
506-
SetBuffer(_inBuff, 0, 0);
507-
}
508-
}
509-
510-
// if there is a remainder it must be last
511-
if (remainderPacketProduced)
512-
{
513-
SetPartialPacket(remainderPacket);
514-
if (!bufferIsPartialCompleted)
515-
{
516-
// we are keeping the partial packet buffer so replace it with a new one
517-
// unless we have already set the buffer to the partial packet buffer
518-
SetBuffer(new byte[_inBuff.Length], 0, 0);
519-
}
520-
}
521-
522-
} while (recurse && _snapshot != null);
523-
524-
if (_snapshot != null)
525-
{
526-
if (_snapshotStatus != SnapshotStatus.NotActive && appended)
527-
{
528-
_snapshot.MoveNext();
529-
#if DEBUG
530-
// multiple packets can be appended by demuxing but we should only move
531-
// forward by a single packet so we can no longer assert that we are on
532-
// the last packet at this time
533-
//_snapshot.AssertCurrent();
534-
#endif
535-
}
536-
}
537-
538-
SniReadStatisticsAndTracing();
539-
SqlClientEventSource.Log.TryAdvancedTraceBinEvent("TdsParser.ReadNetworkPacketAsyncCallback | INFO | ADV | State Object Id {0}, Packet read. In Buffer: {1}, In Bytes Read: {2}", ObjectID, _inBuff, _inBytesRead);
540-
541-
AssertValidState();
542-
}
543-
else
544-
{
545-
throw SQL.ParsingError(ParsingErrorState.ProcessSniPacketFailed);
546-
}
547-
}
548399
}
549400

550401
private void ChangeNetworkPacketTimeout(int dueTime, int period)

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserStateObject.netfx.cs

Lines changed: 1 addition & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -526,155 +526,7 @@ private void ReadSniError(TdsParserStateObject stateObj, uint error)
526526

527527
private uint GetSniPacket(PacketHandle packet, ref uint dataSize)
528528
{
529-
if (error != 0)
530-
{
531-
if ((_parser.State == TdsParserState.Closed) || (_parser.State == TdsParserState.Broken))
532-
{
533-
// Do nothing with callback if closed or broken and error not 0 - callback can occur
534-
// after connection has been closed. PROBLEM IN NETLIB - DESIGN FLAW.
535-
return;
536-
}
537-
538-
AddError(_parser.ProcessSNIError(this));
539-
AssertValidState();
540-
}
541-
else
542-
{
543-
uint dataSize = 0;
544-
bool usedPartialPacket = false;
545-
uint getDataError = 0;
546-
547-
if (usePartialPacket && _snapshot == null && _partialPacket != null && _partialPacket.IsComplete)
548-
{
549-
//Debug.Assert(_snapshot == null, "_snapshot must be null when processing partial packet instead of network read");
550-
//Debug.Assert(_partialPacket != null, "_partialPacket must not be null when usePartialPacket is true");
551-
//Debug.Assert(_partialPacket.IsComplete, "_partialPacket.IsComplete must be true to use it in place of a real read");
552-
SetBuffer(_partialPacket.Buffer, 0, _partialPacket.CurrentLength);
553-
ClearPartialPacket();
554-
getDataError = TdsEnums.SNI_SUCCESS;
555-
usedPartialPacket = true;
556-
}
557-
else
558-
{
559-
getDataError = SNINativeMethodWrapper.SNIPacketGetData(packet, _inBuff, ref dataSize);
560-
}
561-
562-
if (getDataError == TdsEnums.SNI_SUCCESS)
563-
{
564-
if (_inBuff.Length < dataSize)
565-
{
566-
Debug.Assert(true, "Unexpected dataSize on Read");
567-
throw SQL.InvalidInternalPacketSize(StringsHelper.GetString(Strings.SqlMisc_InvalidArraySizeMessage));
568-
}
569-
570-
if (!usedPartialPacket)
571-
{
572-
_lastSuccessfulIOTimer._value = DateTime.UtcNow.Ticks;
573-
574-
SetBuffer(_inBuff, 0, (int)dataSize);
575-
}
576-
577-
bool recurse;
578-
bool appended = false;
579-
do
580-
{
581-
MultiplexPackets(
582-
_inBuff, _inBytesUsed, _inBytesRead,
583-
_partialPacket,
584-
out int newDataOffset,
585-
out int newDataLength,
586-
out Packet remainderPacket,
587-
out bool consumeInputDirectly,
588-
out bool consumePartialPacket,
589-
out bool remainderPacketProduced,
590-
out recurse
591-
);
592-
bool bufferIsPartialCompleted = false;
593-
594-
// if a partial packet was reconstructed it must be handled first
595-
if (consumePartialPacket)
596-
{
597-
if (_snapshot != null)
598-
{
599-
_snapshot.AppendPacketData(_partialPacket.Buffer, _partialPacket.CurrentLength);
600-
appended = true;
601-
}
602-
else
603-
{
604-
SetBuffer(_partialPacket.Buffer, 0, _partialPacket.CurrentLength);
605-
bufferIsPartialCompleted = true;
606-
}
607-
ClearPartialPacket();
608-
}
609-
610-
// if the remaining data can be processed directly it must be second
611-
if (consumeInputDirectly)
612-
{
613-
// if some data was taken from the new packet adjust the counters
614-
if (dataSize != newDataLength || 0 != newDataOffset)
615-
{
616-
SetBuffer(_inBuff, newDataOffset, newDataLength);
617-
}
618-
619-
if (_snapshot != null)
620-
{
621-
_snapshot.AppendPacketData(_inBuff, _inBytesRead);
622-
appended = true;
623-
}
624-
else
625-
{
626-
SetBuffer(_inBuff, 0, _inBytesRead);
627-
}
628-
}
629-
else
630-
{
631-
// whatever is in the input buffer should not be directly consumed
632-
// and is contained in the partial or remainder packets so make sure
633-
// we don't process it
634-
if (!bufferIsPartialCompleted)
635-
{
636-
SetBuffer(_inBuff, 0, 0);
637-
}
638-
}
639-
640-
// if there is a remainder it must be last
641-
if (remainderPacketProduced)
642-
{
643-
SetPartialPacket(remainderPacket);
644-
if (!bufferIsPartialCompleted)
645-
{
646-
// we are keeping the partial packet buffer so replace it with a new one
647-
// unless we have already set the buffer to the partial packet buffer
648-
SetBuffer(new byte[_inBuff.Length], 0, 0);
649-
}
650-
}
651-
652-
} while (recurse && _snapshot != null);
653-
654-
if (_snapshot != null)
655-
{
656-
if (_snapshotStatus != SnapshotStatus.NotActive && appended)
657-
{
658-
_snapshot.MoveNext();
659-
#if DEBUG
660-
// multiple packets can be appended by demuxing but we should only move
661-
// forward by a single packet so we can no longer assert that we are on
662-
// the last packet at this time
663-
//_snapshot.AssertCurrent();
664-
#endif
665-
}
666-
}
667-
668-
SniReadStatisticsAndTracing();
669-
SqlClientEventSource.Log.TryAdvancedTraceBinEvent("TdsParser.ReadNetworkPacketAsyncCallback | INFO | ADV | State Object Id {0}, Packet read. In Buffer: {1}, In Bytes Read: {2}", ObjectID, _inBuff, _inBytesRead);
670-
671-
AssertValidState();
672-
}
673-
else
674-
{
675-
throw SQL.ParsingError(ParsingErrorState.ProcessSniPacketFailed);
676-
}
677-
}
529+
return SNINativeMethodWrapper.SNIPacketGetData(packet, _inBuff, ref dataSize);
678530
}
679531

680532
private void ChangeNetworkPacketTimeout(int dueTime, int period)

0 commit comments

Comments
 (0)