Skip to content

Commit 7bf05ad

Browse files
author
Oleksandr Poliakov
committed
pr
1 parent 7dabafc commit 7bf05ad

File tree

5 files changed

+7
-5
lines changed

5 files changed

+7
-5
lines changed

src/MongoDB.Driver/Core/Configuration/ConnectionString.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ public bool? Ssl
469469
public bool? SslVerifyCertificate => !_tlsInsecure;
470470

471471
/// <summary>
472-
/// Gets the per-operation timeout
472+
/// Gets the per-operation timeout.
473473
/// </summary>
474474
public TimeSpan? Timeout => _timeout;
475475

@@ -1096,7 +1096,7 @@ private void ParseOption(string name, string value)
10961096
break;
10971097
case "timeout":
10981098
case "timeoutms":
1099-
_timeout = ParseTimeSpan(name, value);
1099+
_timeout = value == "0" ? System.Threading.Timeout.InfiniteTimeSpan : ParseTimeSpan(name, value);
11001100
break;
11011101
case "tlsdisablecertificaterevocationcheck":
11021102
var tlsDisableCertificateRevocationCheckValue = ParseBoolean(name, value);

src/MongoDB.Driver/Core/Servers/RoundTripTimeMonitor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ private void MonitorServer()
125125
_logger?.LogDebug(_serverId, "Monitoring started");
126126

127127
var helloOk = false;
128-
using var operationContext = new OperationContext(Timeout.InfiniteTimeSpan, _cancellationToken);
128+
using var operationContext = new OperationContext(null, _cancellationToken);
129129
while (!operationContext.IsCancelledOrTimedOut())
130130
{
131131
try

src/MongoDB.Driver/MongoUrlBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ public override string ToString()
971971
}
972972
if (_timeout.HasValue)
973973
{
974-
query.AppendFormat("timeout={0}&", FormatTimeSpan(_timeout.Value));
974+
query.AppendFormat("timeout={0}&", _timeout == System.Threading.Timeout.InfiniteTimeSpan ? "0" : FormatTimeSpan(_timeout.Value));
975975
}
976976
#pragma warning disable 618
977977
if (_waitQueueMultiple != 0.0 && _waitQueueMultiple != MongoDefaults.WaitQueueMultiple)

tests/MongoDB.Driver.Tests/Core/Configuration/ConnectionStringTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,8 @@ public void When_sslVerifyCertificate_is_specified(string connectionString, bool
10521052
}
10531053

10541054
[Theory]
1055+
[InlineData("mongodb://localhost?timeoutMS=0", -1)]
1056+
[InlineData("mongodb://localhost?timeout=0", -1)]
10551057
[InlineData("mongodb://localhost?timeout=15ms", 15)]
10561058
[InlineData("mongodb://localhost?timeoutMS=15", 15)]
10571059
[InlineData("mongodb://localhost?timeout=15", 1000 * 15)]

tests/MongoDB.Driver.Tests/MongoUrlBuilderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
using System;
1717
using System.Collections.Generic;
1818
using System.Linq;
19-
using System.Threading;
2019
using FluentAssertions;
2120
using MongoDB.Bson.IO;
2221
using MongoDB.Driver.Core.Compression;
@@ -1143,6 +1142,7 @@ public void TestSocketTimeout_Range()
11431142

11441143
[Theory]
11451144
[InlineData(null, "mongodb://localhost", new[] { "" })]
1145+
[InlineData(-1, "mongodb://localhost/?timeout{0}", new[] { "=0", "MS=0" })]
11461146
[InlineData(500, "mongodb://localhost/?timeout{0}", new[] { "=500ms", "=0.5", "=0.5s", "=00:00:00.5", "MS=500" })]
11471147
[InlineData(30000, "mongodb://localhost/?timeout{0}", new[] { "=30s", "=30000ms", "=30", "=0.5m", "=00:00:30", "MS=30000" })]
11481148
[InlineData(1800000, "mongodb://localhost/?timeout{0}", new[] { "=30m", "=1800000ms", "=1800", "=1800s", "=0.5h", "=00:30:00", "MS=1800000" })]

0 commit comments

Comments
 (0)