Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Commit 4ea87d4

Browse files
committed
Rebasing issues
1 parent b3382f5 commit 4ea87d4

File tree

5 files changed

+44
-60
lines changed

5 files changed

+44
-60
lines changed

src/Microsoft.AspNet.Server.Kestrel/Http/Frame.FeatureCollection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ async Task<Stream> IHttpUpgradeFeature.UpgradeAsync()
291291
}
292292
}
293293

294-
await ProduceStartAndFireOnStarting(immediate: true);
294+
await ProduceStartAndFireOnStarting(immediate: true);
295295

296296
return DuplexStream;
297297
}

src/Microsoft.AspNet.Server.Kestrel/Http/Frame.cs

Lines changed: 39 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -826,11 +826,7 @@ private bool TakeStartLine(SocketInput input)
826826
}
827827
}
828828

829-
<<<<<<< HEAD
830829
public static bool TakeMessageHeaders(SocketInput input, FrameRequestHeaders requestHeaders, MemoryPool2 memorypool)
831-
=======
832-
public static bool TakeMessageHeaders(SocketInput input, FrameRequestHeaders requestHeaders)
833-
>>>>>>> 68d63ed... Reduce GetString allocs and conversions
834830
{
835831
var scan = input.ConsumingStart();
836832
var consumed = scan;
@@ -891,61 +887,55 @@ public static bool TakeMessageHeaders(SocketInput input, FrameRequestHeaders req
891887

892888
var wrapping = false;
893889

894-
while (!scan.IsEnd)
890+
var block = memorypool.Lease();
891+
try
895892
{
896-
if (scan.Seek('\r') == -1)
893+
while (!scan.IsEnd)
897894
{
898-
// no "\r" in sight, burn used bytes and go back to await more data
899-
return false;
900-
}
895+
if (scan.Seek('\r') == -1)
896+
{
897+
// no "\r" in sight, burn used bytes and go back to await more data
898+
return false;
899+
}
901900

902-
var endValue = scan;
903-
chFirst = scan.Take(); // expecting: /r
904-
chSecond = scan.Take(); // expecting: /n
901+
var endValue = scan;
902+
chFirst = scan.Take(); // expecting: /r
903+
chSecond = scan.Take(); // expecting: /n
905904

906-
if (chSecond != '\n')
907-
{
908-
// "\r" was all by itself, move just after it and try again
909-
scan = endValue;
910-
scan.Take();
911-
continue;
912-
}
913-
914-
var chThird = scan.Peek();
915-
if (chThird == ' ' || chThird == '\t')
916-
{
917-
// special case, "\r\n " or "\r\n\t".
918-
// this is considered wrapping"linear whitespace" and is actually part of the header value
919-
// continue past this for the next
920-
wrapping = true;
921-
continue;
922-
}
905+
if (chSecond != '\n')
906+
{
907+
// "\r" was all by itself, move just after it and try again
908+
scan = endValue;
909+
scan.Take();
910+
continue;
911+
}
923912

924-
<<<<<<< HEAD
925-
var block = memorypool.Lease();
926-
try
927-
=======
928-
var name = beginName.GetArraySegment(ref endName);
929-
var value = beginValue.GetAsciiString(ref endValue);
930-
if (wrapping)
931-
>>>>>>> 68d63ed... Reduce GetString allocs and conversions
932-
{
933-
var name = beginName.GetArraySegment(endName, block.Data);
934-
var value = beginValue.GetString(endValue);
935-
if (wrapping)
913+
var chThird = scan.Peek();
914+
if (chThird == ' ' || chThird == '\t')
936915
{
937-
value = value.Replace("\r\n", " ");
916+
// special case, "\r\n " or "\r\n\t".
917+
// this is considered wrapping"linear whitespace" and is actually part of the header value
918+
// continue past this for the next
919+
wrapping = true;
920+
continue;
938921
}
939922

940-
consumed = scan;
941-
requestHeaders.Append(name.Array, name.Offset, name.Count, value);
942-
break;
943-
}
944-
finally
945-
{
946-
memorypool.Return(block);
923+
var name = beginName.GetArraySegment(ref endName, block.Data);
924+
var value = beginValue.GetAsciiString(ref endValue);
925+
if (wrapping)
926+
{
927+
value = value.Replace("\r\n", " ");
928+
}
929+
930+
consumed = scan;
931+
requestHeaders.Append(name.Array, name.Offset, name.Count, value);
932+
break;
947933
}
948934
}
935+
finally
936+
{
937+
memorypool.Return(block);
938+
}
949939
}
950940
return false;
951941
}

src/Microsoft.AspNet.Server.Kestrel/Infrastructure/MemoryPool2.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@ public class MemoryPool2 : IDisposable
3131
/// </summary>
3232
private const int _blockLength = _blockStride - _blockUnused;
3333

34-
/// <summary>
35-
/// Max allocation block size for pooled blocks,
36-
/// larger values can be leased but they will be disposed after use rather than returned to the pool.
37-
/// </summary>
38-
public const int MaxPooledBlockLength = _blockLength;
39-
4034
/// <summary>
4135
/// Max allocation block size for pooled blocks,
4236
/// larger values can be leased but they will be disposed after use rather than returned to the pool.

src/Microsoft.AspNet.Server.Kestrel/Infrastructure/MemoryPoolIterator2.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ public string GetUtf8String(ref MemoryPoolIterator2 end)
682682
}
683683
}
684684

685-
public ArraySegment<byte> GetArraySegment(MemoryPoolIterator2 end, ArraySegment<byte> scratchBuffer)
685+
public ArraySegment<byte> GetArraySegment(ref MemoryPoolIterator2 end, ArraySegment<byte> scratchBuffer)
686686
{
687687
if (IsDefault || end.IsDefault)
688688
{
@@ -693,7 +693,7 @@ public ArraySegment<byte> GetArraySegment(MemoryPoolIterator2 end, ArraySegment<
693693
return new ArraySegment<byte>(_block.Array, _index, end._index - _index);
694694
}
695695

696-
var length = GetLength(end);
696+
var length = GetLength(ref end);
697697

698698
if (length < scratchBuffer.Count)
699699
{

test/Microsoft.AspNet.Server.KestrelTests/TestInput.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ class TestInput : IConnectionControl, IFrameControl, IDisposable
1515

1616
public TestInput()
1717
{
18-
var memory2 = new MemoryPool2();
18+
_memory2 = new MemoryPool2();
1919
FrameContext = new FrameContext
2020
{
21-
SocketInput = new SocketInput(memory2),
21+
SocketInput = new SocketInput(_memory2),
2222
ConnectionControl = this,
2323
FrameControl = this
2424
};

0 commit comments

Comments
 (0)