Skip to content

Commit cd3f9ce

Browse files
committed
Bug 36858768 - [36731283->14.1.1.0.19] .NET: deadlock on service start with the EventDispatcher thread (main.net cl 110131 --> 14.1.1.0)
[git-p4: depot-paths = "//dev/release.net/coherence-net-v14.1.1.0/": change = 110135]
1 parent 72f2fe9 commit cd3f9ce

File tree

6 files changed

+23
-98
lines changed

6 files changed

+23
-98
lines changed

src/Coherence/Net/Impl/RemoteService.cs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
2-
* Copyright (c) 2000, 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
5-
* http://oss.oracle.com/licenses/upl.
5+
* https://oss.oracle.com/licenses/upl.
66
*/
77
using System;
88
using System.Diagnostics;
@@ -798,19 +798,6 @@ protected virtual QueueProcessor EnsureEventDispatcher()
798798
return channel.ConnectionManager.EnsureEventDispatcher();
799799
}
800800

801-
/// <summary>
802-
/// Block the calling thread until the EventDispatcher Queue is empty
803-
/// and all outstanding tasks have been executed.
804-
/// </summary>
805-
public virtual void DrainEvents()
806-
{
807-
IConnectionInitiator initiator = Initiator;
808-
if (initiator is Initiator)
809-
{
810-
((Initiator) initiator).DrainEvents();
811-
}
812-
}
813-
814801
/// <summary>
815802
/// Create and dispatch a new local <see cref="MemberEventArgs"/>
816803
/// with the given type to the registered event handlers.

src/Coherence/Net/Impl/SafeCacheService.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
2-
* Copyright (c) 2000, 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
5-
* http://oss.oracle.com/licenses/upl.
5+
* https://oss.oracle.com/licenses/upl.
66
*/
77
using System;
88
using System.Collections;
@@ -44,7 +44,7 @@ public virtual ICollection CacheNames
4444
/// </value>
4545
public virtual ICacheService RunningCacheService
4646
{
47-
get { return EnsureRunningCacheService(true); }
47+
get { return EnsureRunningCacheService(); }
4848
}
4949

5050
/// <summary>
@@ -273,18 +273,12 @@ protected override void Cleanup()
273273
/// running and has not been explicitly stopped, the
274274
/// <b>ICacheService</b> is restarted.
275275
/// </remarks>
276-
/// <param name="drain">
277-
/// If true and the wrapped <b>ICacheService</b> is restarted, the
278-
/// calling thread will be blocked until the wrapped
279-
/// <b>ICacheService</b> event dispatcher queue is empty and all
280-
/// outstanding tasks have been executed.
281-
/// </param>
282276
/// <returns>
283277
/// The running wrapped <b>ICacheService</b>.
284278
/// </returns>
285-
public virtual ICacheService EnsureRunningCacheService(bool drain)
279+
public virtual ICacheService EnsureRunningCacheService()
286280
{
287-
return (ICacheService) EnsureRunningService(drain);
281+
return (ICacheService) EnsureRunningService();
288282
}
289283

290284
/// <summary>

src/Coherence/Net/Impl/SafeInvocationService.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
2-
* Copyright (c) 2000, 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
5-
* http://oss.oracle.com/licenses/upl.
5+
* https://oss.oracle.com/licenses/upl.
66
*/
77
using System.Collections;
88

@@ -25,7 +25,7 @@ public class SafeInvocationService : SafeService, IInvocationService
2525
/// </value>
2626
public virtual IInvocationService RunningInvocationService
2727
{
28-
get { return EnsureRunningInvocationService(true); }
28+
get { return EnsureRunningInvocationService(); }
2929
}
3030

3131
#endregion
@@ -112,20 +112,14 @@ public IDictionary Query(IInvocable task, ICollection col)
112112
/// not running and has not been explicitly stopped, the
113113
/// <b>IInvocationService</b> is restarted.
114114
/// </remarks>
115-
/// <param name="drain">
116-
/// If true and the wrapped <b>IInvocationService</b> is restarted,
117-
/// the calling thread will be blocked until the wrapped
118-
/// <b>IInvocationService</b> event dispatcher queue is empty and all
119-
/// outstanding tasks have been executed.
120-
/// </param>
121115
/// <returns>
122116
/// The running wrapped <b>IInvocationService</b>.
123117
/// </returns>
124-
public virtual IInvocationService EnsureRunningInvocationService(bool drain)
118+
public virtual IInvocationService EnsureRunningInvocationService()
125119
{
126-
return (IInvocationService) EnsureRunningService(drain);
120+
return (IInvocationService) EnsureRunningService();
127121
}
128122

129123
#endregion
130124
}
131-
}
125+
}

src/Coherence/Net/Impl/SafeNamedCache.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
2-
* Copyright (c) 2000, 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
5-
* http://oss.oracle.com/licenses/upl.
5+
* https://oss.oracle.com/licenses/upl.
66
*/
77
using System;
88
using System.Collections;
@@ -197,8 +197,6 @@ public virtual INamedCache RunningNamedCache
197197
}
198198
}
199199
}
200-
201-
safeservice.DrainEvents();
202200
}
203201
return cache;
204202
}
@@ -1517,8 +1515,7 @@ protected virtual INamedCache RestartNamedCache()
15171515
INamedCache cache;
15181516
try
15191517
{
1520-
cache = SafeCacheService.EnsureRunningCacheService(false)
1521-
.EnsureCache(CacheName);
1518+
cache = SafeCacheService.EnsureRunningCacheService().EnsureCache(CacheName);
15221519
}
15231520
finally
15241521
{

src/Coherence/Net/Impl/SafeService.cs

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
2-
* Copyright (c) 2000, 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
5-
* http://oss.oracle.com/licenses/upl.
5+
* https://oss.oracle.com/licenses/upl.
66
*/
77
using System;
88
using System.Runtime.CompilerServices;
@@ -82,7 +82,7 @@ public virtual IOperationalContext OperationalContext
8282
/// </value>
8383
public virtual Util.IService RunningService
8484
{
85-
get { return EnsureRunningService(true); }
85+
get { return EnsureRunningService(); }
8686
}
8787

8888
/// <summary>
@@ -626,16 +626,14 @@ public virtual void Start()
626626

627627
try
628628
{
629-
EnsureRunningService(false);
629+
EnsureRunningService();
630630
}
631631
finally
632632
{
633633
// ServiceState.Started indicates that "start" was called
634634
SafeServiceState = ServiceState.Started;
635635
}
636636
}
637-
638-
DrainEvents();
639637
}
640638

641639
/// <summary>
@@ -829,16 +827,10 @@ public virtual void OnServiceStopped(object sender, ServiceEventArgs evt)
829827
/// before returning it. If the <b>IService</b> is not running and has
830828
/// not been explicitly stopped, the <b>IService</b> is restarted.
831829
/// </remarks>
832-
/// <param name="drain">
833-
/// If true and the wrapped <b>IService</b> is restarted, the calling
834-
/// thread will be blocked until the wrapped <b>IService</b> event
835-
/// dispatcher queue is empty and all outstanding tasks have been
836-
/// executed.
837-
/// </param>
838830
/// <returns>
839831
/// The running wrapped <b>IService</b>.
840832
/// </returns>
841-
public virtual Util.IService EnsureRunningService(bool drain)
833+
public virtual Util.IService EnsureRunningService()
842834
{
843835
Util.IService service = Service;
844836
if (service == null || !service.IsRunning)
@@ -881,34 +873,11 @@ public virtual Util.IService EnsureRunningService(bool drain)
881873
}
882874
}
883875
}
884-
885-
if (drain)
886-
{
887-
DrainEvents();
888-
}
889876
}
890877

891878
return service;
892879
}
893880

894-
/// <summary>
895-
/// Block the calling thread until the wrapped <b>IService</b> event
896-
/// dispatcher queue is empty and all outstanding tasks have been
897-
/// executed.
898-
/// </summary>
899-
public virtual void DrainEvents()
900-
{
901-
Util.IService service = Service;
902-
if (service is Service)
903-
{
904-
((Service) service).DrainEvents();
905-
}
906-
else if (service is RemoteService)
907-
{
908-
((RemoteService) service).DrainEvents();
909-
}
910-
}
911-
912881
/// <summary>
913882
/// Cleanup used resources.
914883
/// </summary>

src/Coherence/Util/Daemon/QueueProcessor/Service/Service.cs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
2-
* Copyright (c) 2000, 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
5-
* http://oss.oracle.com/licenses/upl.
5+
* https://oss.oracle.com/licenses/upl.
66
*/
77
using System;
88
using System.Diagnostics;
@@ -989,22 +989,6 @@ private void InvokeServiceEvent(ServiceEventHandler handler, ServiceEventArgs ev
989989
}
990990
}
991991

992-
/// <summary>
993-
/// Block the calling thread until the EventDispatcher Queue is empty
994-
/// and all outstanding tasks have been executed.
995-
/// </summary>
996-
/// <remarks>
997-
/// This method is mostly called on client threads.
998-
/// </remarks>
999-
public virtual void DrainEvents()
1000-
{
1001-
EventDispatcher daemon = Dispatcher;
1002-
if (daemon != null)
1003-
{
1004-
daemon.DrainQueue();
1005-
}
1006-
}
1007-
1008992
/// <summary>
1009993
/// Return a running <see cref="Dispatcher"/>.
1010994
/// </summary>

0 commit comments

Comments
 (0)