-
Notifications
You must be signed in to change notification settings - Fork 1.3k
CSHARP-3662: MongoClientSettings.SocketTimeout does not work for values under 500ms on Windows for sync code #1690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -333,14 +333,15 @@ private IByteBuffer ReceiveBuffer(CancellationToken cancellationToken) | |
try | ||
{ | ||
var messageSizeBytes = new byte[4]; | ||
_stream.ReadBytes(messageSizeBytes, 0, 4, cancellationToken); | ||
var readTimeout = _stream.CanTimeout ? TimeSpan.FromMilliseconds(_stream.ReadTimeout) : Timeout.InfiniteTimeSpan; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems weird to be getting the Also, why do we care about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code is inhereted/copied from the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. Should I remove checking the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I think we can ignore this now as we are doing our own timeouts. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As it was discussed offline - will keep it for now. It will be replaced by CSOT timeout on the later stages of implementation. |
||
_stream.ReadBytes(messageSizeBytes, 0, 4, readTimeout, cancellationToken); | ||
var messageSize = BinaryPrimitives.ReadInt32LittleEndian(messageSizeBytes); | ||
EnsureMessageSizeIsValid(messageSize); | ||
var inputBufferChunkSource = new InputBufferChunkSource(BsonChunkPool.Default); | ||
var buffer = ByteBufferFactory.Create(inputBufferChunkSource, messageSize); | ||
buffer.Length = messageSize; | ||
buffer.SetBytes(0, messageSizeBytes, 0, 4); | ||
_stream.ReadBytes(buffer, 4, messageSize - 4, cancellationToken); | ||
_stream.ReadBytes(buffer, 4, messageSize - 4, readTimeout, cancellationToken); | ||
_lastUsedAtUtc = DateTime.UtcNow; | ||
buffer.MakeReadOnly(); | ||
return buffer; | ||
|
@@ -535,7 +536,8 @@ private void SendBuffer(IByteBuffer buffer, CancellationToken cancellationToken) | |
|
||
try | ||
{ | ||
_stream.WriteBytes(buffer, 0, buffer.Length, cancellationToken); | ||
var writeTimeout = _stream.CanTimeout ? TimeSpan.FromMilliseconds(_stream.WriteTimeout) : Timeout.InfiniteTimeSpan; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar question here as for |
||
_stream.WriteBytes(buffer, 0, buffer.Length, writeTimeout, cancellationToken); | ||
_lastUsedAtUtc = DateTime.UtcNow; | ||
} | ||
catch (Exception ex) | ||
|
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.
Curious why this change is needed.
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.
Because this code uses helper method that I've adjusted with new parameter, so I should pass something from here too.
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
stream.ReadTimeout
still be respected byBeginRead
?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.
As far as I understood Compress/Decompress works only with in-memory kind of streams. Not sure if timeout makes sense in such case.