Skip to content

Commit 9b340dc

Browse files
authored
Merge branch '6.x' into fnel/6.x/fix-buffer-overflow
2 parents a437217 + 1fac6fc commit 9b340dc

17 files changed

+237
-51
lines changed

.github/workflows/main.yaml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: rabbitmq-dotnet-client
2+
3+
on:
4+
push:
5+
branches: [ 6.x ]
6+
pull_request:
7+
branches: [ 6.x ]
8+
9+
jobs:
10+
build-win32:
11+
name: build/test on windows-latest
12+
13+
runs-on: windows-latest
14+
15+
# https://github.com/NuGet/Home/issues/11548
16+
env:
17+
NUGET_CERT_REVOCATION_MODE: offline
18+
19+
steps:
20+
- name: Clone repository
21+
uses: actions/checkout@v2
22+
with:
23+
submodules: true
24+
- name: Cache installers
25+
uses: actions/cache@v2
26+
with:
27+
# Note: the cache path is relative to the workspace directory
28+
# https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#using-the-cache-action
29+
path: ~/installers
30+
key: ${{ runner.os }}-v0-${{ hashFiles('tools/versions.json') }}
31+
- name: Cache NuGet packages
32+
uses: actions/cache@v2
33+
with:
34+
path: |
35+
~/.nuget/packages
36+
~/AppData/Local/NuGet/v3-cache
37+
key: ${{ runner.os }}-v0-nuget-${{ hashFiles('**/*.csproj') }}
38+
restore-keys: |
39+
${{ runner.os }}-v0-nuget-
40+
- name: Install and start RabbitMQ
41+
run: ./tools/install.ps1
42+
- name: List NuGet sources
43+
run: dotnet nuget locals all --list
44+
- name: Restore
45+
run: dotnet restore --verbosity=normal
46+
- name: ApiGen
47+
run: dotnet run --project ./projects/Apigen/Apigen.csproj --apiName:AMQP_0_9_1 ./projects/specs/amqp0-9-1.stripped.xml ./gensrc/autogenerated-api-0-9-1.cs
48+
- name: Build
49+
run: dotnet build --no-restore --verbosity=normal
50+
- name: Test
51+
run: ./tools/gha-run-tests.ps1
52+
53+
build:
54+
name: build/test on ubuntu-latest
55+
56+
runs-on: ubuntu-latest
57+
58+
services:
59+
rabbitmq:
60+
image: pivotalrabbitmq/rabbitmq:master-otp-max
61+
ports:
62+
- 5672:5672
63+
- 15672:15672
64+
65+
steps:
66+
- name: Clone repository
67+
uses: actions/checkout@v2
68+
with:
69+
submodules: true
70+
- name: Setup .NET
71+
uses: actions/setup-dotnet@v1
72+
with:
73+
dotnet-version: 3.1.x
74+
- name: Cache NuGet packages
75+
uses: actions/cache@v2
76+
with:
77+
path: |
78+
~/.nuget/packages
79+
~/.local/share/NuGet/v3-cache
80+
key: ${{ runner.os }}-v0-nuget-${{ hashFiles('**/*.csproj') }}
81+
restore-keys: |
82+
${{ runner.os }}-v0-nuget-
83+
- name: Restore
84+
run: dotnet restore --verbosity=normal
85+
- name: ApiGen
86+
run: dotnet run --project ./projects/Apigen/Apigen.csproj --apiName:AMQP_0_9_1 ./projects/specs/amqp0-9-1.stripped.xml ./gensrc/autogenerated-api-0-9-1.cs
87+
- name: Build
88+
run: dotnet build --no-restore --verbosity=normal
89+
- name: Test
90+
run: dotnet test --no-restore --no-build --logger "console;verbosity=detailed" --framework "netcoreapp3.1"
91+
env:
92+
RABBITMQ_RABBITMQCTL_PATH: DOCKER:${{job.services.rabbitmq.id}}

_site

Submodule _site updated 166 files

build.bat

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@ECHO OFF
22
set DOTNET_CLI_TELEMETRY_OPTOUT=1
3-
dotnet restore .\RabbitMQDotNetClient.sln
4-
dotnet run --project .\projects\Apigen\Apigen.csproj --apiName:AMQP_0_9_1 .\projects\specs\amqp0-9-1.stripped.xml .\gensrc\autogenerated-api-0-9-1.cs
5-
dotnet build .\RabbitMQDotNetClient.sln
3+
dotnet restore --verbosity=normal .\RabbitMQDotNetClient.sln
4+
dotnet run --verbosity=normal --project .\projects\Apigen\Apigen.csproj --apiName:AMQP_0_9_1 .\projects\specs\amqp0-9-1.stripped.xml .\gensrc\autogenerated-api-0-9-1.cs
5+
dotnet build --verbosity=normal .\RabbitMQDotNetClient.sln

projects/RabbitMQ.Client/RabbitMQ.Client.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<PackageTags>rabbitmq, amqp</PackageTags>
1818
<Product>RabbitMQ</Product>
1919
<PublishRepositoryUrl>true</PublishRepositoryUrl>
20+
<RepositoryUrl>https://github.com/rabbitmq/rabbitmq-dotnet-client.git</RepositoryUrl>
2021
<IncludeSymbols>true</IncludeSymbols>
2122
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
2223
<AssemblyOriginatorKeyFile>../rabbit.snk</AssemblyOriginatorKeyFile>

projects/RabbitMQ.Client/client/impl/AsyncConsumerWorkService.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,14 @@ private static async Task HandleConcurrent(Work work, IModel model, SemaphoreSli
182182
finally
183183
{
184184
work.PostExecute();
185-
limiter.Release();
185+
186+
try
187+
{
188+
limiter.Release();
189+
}
190+
catch (ObjectDisposedException) // Prevents Exceptions in the Task's finalizer when the WorkPool is Stopped
191+
{
192+
}
186193
}
187194
}
188195

projects/RabbitMQ.Client/client/impl/AutorecoveringConnection.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,24 @@ private bool TryPerformAutomaticRecovery()
451451
catch (Exception e)
452452
{
453453
ESLog.Error("Exception when recovering connection. Will try again after retry interval.", e);
454+
455+
try
456+
{
457+
/*
458+
* To prevent connection leaks on the next recovery loop,
459+
* we abort the delegated connection if it is still open.
460+
* We do not want to block the abort forever (potentially deadlocking recovery),
461+
* so we specify the same configured timeout used for connection.
462+
*/
463+
if (_delegate?.IsOpen == true)
464+
{
465+
_delegate.Abort(Constants.InternalError, "FailedAutoRecovery", ShutdownInitiator.Library, _factory.RequestedConnectionTimeout);
466+
}
467+
}
468+
catch (Exception e2)
469+
{
470+
ESLog.Warn("Exception when aborting previous auto recovery connection.", e2);
471+
}
454472
}
455473

456474
return false;
@@ -672,7 +690,6 @@ private void Init(IFrameHandler fh)
672690
lock (_eventLock)
673691
{
674692
ConnectionShutdown += recoveryListener;
675-
_recordedShutdownEventHandlers += recoveryListener;
676693
}
677694
}
678695

projects/RabbitMQ.Client/client/impl/AutorecoveringModel.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,12 +441,19 @@ public void AutomaticallyRecover(AutorecoveringConnection conn, bool recoverCons
441441
newModel.TxSelect();
442442
}
443443

444+
/*
445+
* https://github.com/rabbitmq/rabbitmq-dotnet-client/issues/1140
446+
* If this assignment is not done before recovering consumers, there is a good
447+
* chance that an invalid Model will be used to handle a basic.deliver frame,
448+
* with the resulting basic.ack never getting sent out.
449+
*/
450+
_delegate = newModel;
451+
444452
if (recoverConsumers)
445453
{
446454
_connection.RecoverConsumers(this, newModel);
447455
}
448456

449-
_delegate = newModel;
450457
RunRecoveryEventHandlers();
451458
}
452459

projects/RabbitMQ.Client/client/impl/Connection.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,15 @@ public Connection(IConnectionFactory factory, bool insist, IFrameHandler frameHa
116116
_model0 = (ModelBase)Protocol.CreateModel(_session0);
117117

118118
StartMainLoop(factory.UseBackgroundThreadsForIO);
119-
Open(insist);
119+
try
120+
{
121+
Open(insist);
122+
}
123+
catch
124+
{
125+
TerminateMainloop();
126+
throw;
127+
}
120128
}
121129

122130
public Guid Id { get { return _id; } }

projects/RabbitMQ.Client/client/impl/SocketFrameHandler.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,17 +193,18 @@ public void Close()
193193
try
194194
{
195195
_channelWriter.Complete();
196-
_writerTask.GetAwaiter().GetResult();
196+
_writerTask?.GetAwaiter().GetResult();
197197
}
198-
catch(Exception)
198+
catch
199199
{
200+
// ignore, we are closing anyway
200201
}
201202

202203
try
203204
{
204205
_socket.Close();
205206
}
206-
catch (Exception)
207+
catch
207208
{
208209
// ignore, we are closing anyway
209210
}

projects/Unit/APIApproval.Approve.verified.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -847,13 +847,13 @@ namespace RabbitMQ.Client.Logging
847847
{
848848
public static RabbitMQ.Client.Logging.RabbitMqClientEventSource Log;
849849
public RabbitMqClientEventSource() { }
850-
[System.Diagnostics.Tracing.Event(3, Keywords=System.Diagnostics.Tracing.EventKeywords.None | System.Diagnostics.Tracing.EventKeywords.All, Level=System.Diagnostics.Tracing.EventLevel.Error, Message="ERROR")]
850+
[System.Diagnostics.Tracing.Event(3, Keywords=System.Diagnostics.Tracing.EventKeywords.None, Level=System.Diagnostics.Tracing.EventLevel.Error, Message="ERROR")]
851851
public void Error(string message, RabbitMQ.Client.Logging.RabbitMqExceptionDetail ex) { }
852852
[System.Diagnostics.Tracing.NonEvent]
853853
public void Error(string message, System.Exception ex) { }
854-
[System.Diagnostics.Tracing.Event(1, Keywords=System.Diagnostics.Tracing.EventKeywords.None | System.Diagnostics.Tracing.EventKeywords.All, Level=System.Diagnostics.Tracing.EventLevel.Informational, Message="INFO")]
854+
[System.Diagnostics.Tracing.Event(1, Keywords=System.Diagnostics.Tracing.EventKeywords.None, Level=System.Diagnostics.Tracing.EventLevel.Informational, Message="INFO")]
855855
public void Info(string message) { }
856-
[System.Diagnostics.Tracing.Event(2, Keywords=System.Diagnostics.Tracing.EventKeywords.None | System.Diagnostics.Tracing.EventKeywords.All, Level=System.Diagnostics.Tracing.EventLevel.Warning, Message="WARN")]
856+
[System.Diagnostics.Tracing.Event(2, Keywords=System.Diagnostics.Tracing.EventKeywords.None, Level=System.Diagnostics.Tracing.EventLevel.Warning, Message="WARN")]
857857
public void Warn(string message) { }
858858
public class Keywords
859859
{

0 commit comments

Comments
 (0)