File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
src/NServiceBus.Transport.SqlServer/Receiving Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -95,11 +95,17 @@ public Task StartReceive(CancellationToken cancellationToken = default)
9595
9696 public async Task ChangeConcurrency ( PushRuntimeSettings newLimitations , CancellationToken cancellationToken = default )
9797 {
98- var oldLimiter = concurrencyLimiter ;
99- var oldMaxConcurrency = maxConcurrency ;
100- concurrencyLimiter = new SemaphoreSlim ( newLimitations . MaxConcurrency ) ;
101- limitations = newLimitations ;
102- maxConcurrency = limitations . MaxConcurrency ;
98+ SemaphoreSlim oldLimiter ;
99+ int oldMaxConcurrency ;
100+
101+ lock ( lockObject )
102+ {
103+ oldLimiter = concurrencyLimiter ;
104+ oldMaxConcurrency = maxConcurrency ;
105+ concurrencyLimiter = new SemaphoreSlim ( newLimitations . MaxConcurrency ) ;
106+ limitations = newLimitations ;
107+ maxConcurrency = limitations . MaxConcurrency ;
108+ }
103109
104110 try
105111 {
@@ -279,5 +285,7 @@ async Task PurgeExpiredMessages(CancellationToken cancellationToken)
279285 public ISubscriptionManager Subscriptions { get ; }
280286 public string Id { get ; }
281287 public string ReceiveAddress { get ; }
288+
289+ public static object lockObject = new ( ) ;
282290 }
283291}
You can’t perform that action at this time.
0 commit comments