-
Notifications
You must be signed in to change notification settings - Fork 524
Conversation
- Removed shutdown bools
- Use LibuvAwaitable instead of having all of that state on the UvWriteReq - Remove Console output from TestApplicationErrorLogger
- Reduce the lock in output to avoid deadlocks - Pin memory instead of using TryGetPointer in UvWriteReq
samples/SampleApp/Startup.cs
Outdated
|
||
listenOptions.UseConnectionLogging(); | ||
// listenOptions.UseConnectionLogging(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will revert
MaximumSizeHigh = ServiceContext.ServerOptions.Limits.MaxResponseBufferSize ?? 0, | ||
MaximumSizeLow = ServiceContext.ServerOptions.Limits.MaxResponseBufferSize ?? 0 | ||
}; | ||
|
||
public PipeOptions AdaptedPipeOptions => new PipeOptions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs some tweaking. We don't want request limits for both pipes in the adapter.
@@ -86,5 +89,19 @@ public static ArraySegment<byte> GetArray(this Memory<byte> memory) | |||
} | |||
return result; | |||
} | |||
|
|||
public static void WriteAscii(this WritableBuffer buffer, string data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be optimized /cc @benaadams 😄
|
||
public static void WriteNumeric(this WritableBuffer buffer, ulong number) | ||
{ | ||
buffer.Write(number.ToString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugh 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wtf?
Debug.Assert(tryGetPointerResult); | ||
// REVIEW: This isn't necessary for our default pool since the memory is | ||
// already pinned but it also makes tests pass | ||
var memoryHandle = memory.Pin(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That test is wrong, passing ReadableBuffer.Create
result which is array based and unexpected. We should just change the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It isn't wrong, just unnecessary if we were to use pre pinned buffers. I also think the overhead is negligible
@@ -17,7 +16,7 @@ public class TestApplicationErrorLogger : ILogger | |||
|
|||
public bool ThrowOnCriticalErrors { get; set; } = true; | |||
|
|||
public List<LogMessage> Messages { get; } = new List<LogMessage>(); | |||
public ConcurrentBag<LogMessage> Messages { get; } = new ConcurrentBag<LogMessage>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going for eventually consistent model 😆
ConcurrentQueue?
- Deleted MemoryPool and friends and tests
adapterContext.ConnectionStream, | ||
Thread.PipelineFactory.Create(ListenerContext.AdaptedPipeOptions), | ||
Thread.Memory, | ||
Log); | ||
Thread.PipelineFactory.Create(ListenerContext.AdaptedPipeOptions)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use named args here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't tell what is what.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only do that for bools and null args.
{ | ||
public class LibuvAwaitable<TRequest> : ICriticalNotifyCompletion where TRequest : UvRequest | ||
{ | ||
private readonly static Action CALLBACK_RAN = () => { }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WHY CAPS
//namespace Microsoft.AspNetCore.Server.KestrelTests | ||
//{ | ||
// public class SocketOutputTests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it works?
ReaderScheduler = Thread, | ||
WriterScheduler = ServiceContext.ThreadPool, | ||
MaximumSizeHigh = ServiceContext.ServerOptions.Limits.MaxResponseBufferSize ?? 0, | ||
MaximumSizeLow = ServiceContext.ServerOptions.Limits.MaxResponseBufferSize ?? 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a new option is needed.
Self._head = null; | ||
Self._tail = null; | ||
returnAll = true; | ||
// REVIEW: Locking here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
|
||
namespace Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure | ||
{ | ||
public class LibuvAwaitable<TRequest> : ICriticalNotifyCompletion where TRequest : UvRequest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: put where
clause in it's own line
|
||
public struct UvWriteResult | ||
{ | ||
public int Status; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
readonly
|
||
private int _status; | ||
|
||
public static Action<TRequest, int, Exception, object> Callback = (req, status, error, state) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
readonly
Input = pipe; | ||
Output = new StreamSocketOutput(connectionId, filteredStream, memory, logger); | ||
Input = inputPipe; | ||
_output = new StreamSocketOutput(filteredStream, outputPipe); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merge StreamSocketOutput
into AdaptedPipeline
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the next round
if (buffer.IsEmpty) | ||
{ | ||
await _outputStream.FlushAsync(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else?
{ | ||
TaskCompletionSource<object> tcs = null; | ||
var scheduleWrite = false; | ||
var flushAwaiter = default(WritableBufferAwaitable); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WritableBufferAwaitable flushAwaiter;
socketShutdownSend: false, | ||
socketDisconnect: true, | ||
isSync: true); | ||
// Not graceful |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
turn switch to if?
Will make all of the nit feedback in a subsequent commit. |
This is merged |
MemoryPoolIterator
for output now usesWritableBuffer
UvWriteReq
async/await friendly withLibuvAwaitable<T>
TODO:
Cancellation isn't handled, it needs to be.Will do this in another PR once we get Add cancellation token support to FlushAsync and ReadAsync dotnet/corefxlab#1332Little bit cleanupPort relevantSocketOutput
tests (they are commented out now)/cc @pakrym