-
Notifications
You must be signed in to change notification settings - Fork 593
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
Misc fixes to C# locator discovery #3177
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 |
---|---|---|
|
@@ -11,11 +11,6 @@ public Ice.Plugin | |
create(Ice.Communicator communicator, string name, string[] args) => new PluginI(communicator); | ||
} | ||
|
||
public interface Plugin : Ice.Plugin | ||
{ | ||
List<Ice.LocatorPrx> getLocators(string instanceName, int waitTime); | ||
} | ||
|
||
internal class Request : TaskCompletionSource<Ice.Object_Ice_invokeResult> | ||
{ | ||
public Request( | ||
|
@@ -206,48 +201,6 @@ public override Task<Ice.Object_Ice_invokeResult> | |
} | ||
} | ||
|
||
public List<Ice.LocatorPrx> getLocators(string instanceName, int waitTime) | ||
{ | ||
// | ||
// Clear locators from previous search. | ||
// | ||
lock (_mutex) | ||
{ | ||
_locators.Clear(); | ||
} | ||
|
||
// | ||
// Find a locator | ||
// | ||
invoke(null, null); | ||
|
||
// | ||
// Wait for responses | ||
// | ||
if (instanceName.Length == 0) | ||
{ | ||
Thread.Sleep(waitTime); | ||
} | ||
else | ||
{ | ||
lock (_mutex) | ||
{ | ||
while (!_locators.ContainsKey(instanceName) && _pending) | ||
{ | ||
Monitor.Wait(_mutex, waitTime); | ||
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. The only Monitor.Wait(_mutex, ...), which means all the Monitor.Pulse(_mutex) elsewhere are useless. |
||
} | ||
} | ||
} | ||
|
||
// | ||
// Return found locators | ||
// | ||
lock (_mutex) | ||
{ | ||
return new List<Ice.LocatorPrx>(_locators.Values); | ||
} | ||
} | ||
|
||
public void | ||
foundLocator(Ice.LocatorPrx locator) | ||
{ | ||
|
@@ -363,7 +316,6 @@ public void | |
if (_pendingRequests.Count == 0) | ||
{ | ||
_locators[locator.ice_getIdentity().category] = l; | ||
Monitor.Pulse(_mutex); | ||
} | ||
else | ||
{ | ||
|
@@ -427,7 +379,7 @@ public void | |
|
||
foreach (var l in _lookups) | ||
{ | ||
_ = preformFindLocatorAsync(l.Key, l.Value); | ||
_ = performFindLocatorAsync(l.Key, l.Value); | ||
} | ||
_timer.schedule(this, _timeout); | ||
} | ||
|
@@ -457,8 +409,11 @@ public void | |
} | ||
} | ||
|
||
async Task preformFindLocatorAsync(LookupPrx lookupPrx, LookupReplyPrx lookupReplyPrx) | ||
async Task performFindLocatorAsync(LookupPrx lookupPrx, LookupReplyPrx lookupReplyPrx) | ||
{ | ||
// Exit the mutex lock before proceeding. | ||
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. Awaiting a remote call with a mutex lock (see below) is incorrect and deadlock prone. It could be the cause for #2813. |
||
await Task.Yield(); | ||
|
||
// Send multicast request. | ||
try | ||
{ | ||
|
@@ -507,11 +462,7 @@ private void exception(Exception ex) | |
_lookup.ice_getCommunicator().getLogger().trace("Lookup", s.ToString()); | ||
} | ||
|
||
if (_pendingRequests.Count == 0) | ||
{ | ||
Monitor.Pulse(_mutex); | ||
} | ||
else | ||
if (_pendingRequests.Count > 0) | ||
{ | ||
foreach (Request req in _pendingRequests) | ||
{ | ||
|
@@ -589,11 +540,7 @@ public void runTimerTask() | |
_lookup.ice_getCommunicator().getLogger().trace("Lookup", s.ToString()); | ||
} | ||
|
||
if (_pendingRequests.Count == 0) | ||
{ | ||
Monitor.Pulse(_mutex); | ||
} | ||
else | ||
if (_pendingRequests.Count > 0) | ||
{ | ||
foreach (Request req in _pendingRequests) | ||
{ | ||
|
@@ -740,12 +687,6 @@ public void | |
} | ||
} | ||
|
||
private List<Ice.LocatorPrx> | ||
getLocators(string instanceName, int waitTime) | ||
{ | ||
return _locator.getLocators(instanceName, waitTime); | ||
} | ||
|
||
private Ice.Communicator _communicator; | ||
private Ice.ObjectAdapter _locatorAdapter; | ||
private Ice.ObjectAdapter _replyAdapter; | ||
|
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.
We use this (obviously) internal API in C++ and Java, but not in C#, where it's internal unused code.