mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-21 23:29:52 +01:00
Ensure the semaphore is released if a RuntimeException is thrown.
This commit is contained in:
@@ -137,13 +137,15 @@ class ModemPlugin implements DuplexPlugin, Modem.Callback {
|
|||||||
LOG.info("Previous poll still in progress");
|
LOG.info("Previous poll still in progress");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
// Get the ISO 3166 code for the caller's country
|
// Get the ISO 3166 code for the caller's country
|
||||||
String callerIso = callback.getLocalProperties().get("iso3166");
|
String callerIso = callback.getLocalProperties().get("iso3166");
|
||||||
if(StringUtils.isNullOrEmpty(callerIso)) return;
|
if(StringUtils.isNullOrEmpty(callerIso)) return;
|
||||||
// Call contacts one at a time in a random order
|
// Call contacts one at a time in a random order
|
||||||
Map<ContactId, TransportProperties> remote =
|
Map<ContactId, TransportProperties> remote =
|
||||||
callback.getRemoteProperties();
|
callback.getRemoteProperties();
|
||||||
List<ContactId> contacts = new ArrayList<ContactId>(remote.keySet());
|
List<ContactId> contacts =
|
||||||
|
new ArrayList<ContactId>(remote.keySet());
|
||||||
Collections.shuffle(contacts);
|
Collections.shuffle(contacts);
|
||||||
Iterator<ContactId> it = contacts.iterator();
|
Iterator<ContactId> it = contacts.iterator();
|
||||||
while(it.hasNext() && running) {
|
while(it.hasNext() && running) {
|
||||||
@@ -163,7 +165,8 @@ class ModemPlugin implements DuplexPlugin, Modem.Callback {
|
|||||||
try {
|
try {
|
||||||
if(!modem.dial(number)) continue;
|
if(!modem.dial(number)) continue;
|
||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
if(LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
|
if(LOG.isLoggable(WARNING))
|
||||||
|
LOG.log(WARNING, e.toString(), e);
|
||||||
if(resetModem()) continue;
|
if(resetModem()) continue;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -179,8 +182,10 @@ class ModemPlugin implements DuplexPlugin, Modem.Callback {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
polling.release();
|
polling.release();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public DuplexTransportConnection createConnection(ContactId c) {
|
public DuplexTransportConnection createConnection(ContactId c) {
|
||||||
if(!running) return null;
|
if(!running) return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user