Skip to content
This repository was archived by the owner on Mar 19, 2019. It is now read-only.

Add flag to disable synchronous IO #371

Merged
merged 1 commit into from
Jul 5, 2017
Merged

Add flag to disable synchronous IO #371

merged 1 commit into from
Jul 5, 2017

Conversation

Tratcher
Copy link
Member

#366 Read, Write, and Flush now throw by default. There's some debate on Flush because it breaks StreamWriter.Dispose().

@Tratcher Tratcher added this to the 2.0.0 milestone Jun 27, 2017
@Tratcher Tratcher self-assigned this Jun 27, 2017
@@ -111,6 +112,10 @@ private void ValidateReadBuffer(byte[] buffer, int offset, int size)

public override unsafe int Read([In, Out] byte[] buffer, int offset, int size)
{
if (!RequestContext.AllowSynchronousIO)
{
throw new InvalidOperationException("Syncronous IO APIs are disabled, see AllowSynchronousIO.");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Synchronous

@@ -91,10 +91,16 @@ public override long Position
// Send headers
public override void Flush()
{
if (!RequestContext.AllowSynchronousIO)
{
throw new InvalidOperationException("Syncronous IO APIs are disabled, see AllowSynchronousIO.");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Synchronous

@@ -449,9 +455,15 @@ private HttpApi.HTTP_FLAGS ComputeLeftToWrite(long writeCount, bool endOfRequest

public override void Write(byte[] buffer, int offset, int count)
{
if (!RequestContext.AllowSynchronousIO)
{
throw new InvalidOperationException("Syncronous IO APIs are disabled, see AllowSynchronousIO.");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Synchronous

@Tratcher Tratcher force-pushed the tratcher/nosync branch 2 times, most recently from 0c1f285 to b2eaf80 Compare July 5, 2017 22:33
@Tratcher
Copy link
Member Author

Tratcher commented Jul 5, 2017

Updated to enable sync by default.

if (!RequestContext.AllowSynchronousIO)
{
throw new InvalidOperationException("Synchronous IO APIs are disabled, see AllowSynchronousIO.");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: newline.

}
}

[ConditionalFact]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, where is the condition?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public async Task RequestBody_ReadSync_Success()
{
string address;
using (var server = Utilities.CreateHttpServer(out address))
{
Task<string> responseTask = SendRequestAsync(address, "Hello World");

server.Options.AllowSynchronousIO = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these lines in your tests still necessary now the true is the default?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not at the moment, but they will be when we switch the default and since I had already fixed them there was no point in reverting it.

@Tratcher Tratcher merged commit 13b867a into dev Jul 5, 2017
@Tratcher Tratcher deleted the tratcher/nosync branch July 5, 2017 22:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants