You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use an IBufferWriter<byte> to write the outgoing SSPI blob (#2452)
* Use an IBufferWriter<byte> to write the outgoing SSPI blob
This change removes the need to pre-allocate anything for the outgoing blobs of SSPI generation. As part of this:
- An internal implementation of ArrayBufferWriter is added for platforms that do not support it
- SqlObjectPool is imbued with the ability to create/reset pooled objects
- TdsParser/TdsLogin is updated to use pooled ArrayBufferWriter instances to generate SSPI blobs
- Native methods are updated to take in Span/* for writeable byte[]
- SSPIContextProvider signature is updated to take IBufferWriter
boolasync=_parser._asyncWrite;// NOTE: We are capturing this now for the assert after the Task is returned, since WritePacket will turn off async if there is an exception
821
-
Debug.Assert(async ||_asyncWriteCount==0);
822
-
// Do we have to send out in packet size chunks, or can we rely on netlib layer to break it up?
823
-
// would prefer to do something like:
824
-
//
825
-
// if (len > what we have room for || len > out buf)
826
-
// flush buffer
827
-
// UnsafeNativeMethods.Write(b)
828
-
//
829
-
830
-
intoffset= offsetBuffer;
831
-
832
-
Debug.Assert(b.Length>=len,"Invalid length sent to WriteBytes()!");
833
-
834
-
// loop through and write the entire array
835
-
do
836
-
{
837
-
if((_outBytesUsed+len)>_outBuff.Length)
838
-
{
839
-
// If the remainder of the data won't fit into the buffer, then we have to put
840
-
// whatever we can into the buffer, and flush that so we can then put more into
boolasync=_parser._asyncWrite;// NOTE: We are capturing this now for the assert after the Task is returned, since WritePacket will turn off async if there is an exception
876
-
Debug.Assert(async ||_asyncWriteCount==0);
877
-
// Do we have to send out in packet size chunks, or can we rely on netlib layer to break it up?
878
-
// would prefer to do something like:
879
-
//
880
-
// if (len > what we have room for || len > out buf)
881
-
// flush buffer
882
-
// UnsafeNativeMethods.Write(b)
883
-
//
884
-
885
-
intoffset= offsetBuffer;
886
-
887
-
Debug.Assert(b.Length>=len,"Invalid length sent to WriteByteArray()!");
888
-
889
-
// loop through and write the entire array
890
-
do
891
-
{
892
-
if((_outBytesUsed+len)>_outBuff.Length)
893
-
{
894
-
// If the remainder of the data won't fit into the buffer, then we have to put
895
-
// whatever we can into the buffer, and flush that so we can then put more into
0 commit comments