Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
briar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julian Dehm
briar
Commits
a7acec8f
Commit
a7acec8f
authored
12 years ago
by
akwizgran
Browse files
Options
Downloads
Patches
Plain Diff
Ensure the semaphore is released if a RuntimeException is thrown.
parent
7887331d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
briar-core/src/net/sf/briar/plugins/modem/ModemPlugin.java
+46
-41
46 additions, 41 deletions
briar-core/src/net/sf/briar/plugins/modem/ModemPlugin.java
with
46 additions
and
41 deletions
briar-core/src/net/sf/briar/plugins/modem/ModemPlugin.java
+
46
−
41
View file @
a7acec8f
...
...
@@ -137,49 +137,54 @@ class ModemPlugin implements DuplexPlugin, Modem.Callback {
LOG
.
info
(
"Previous poll still in progress"
);
return
;
}
// Get the ISO 3166 code for the caller's country
String
callerIso
=
callback
.
getLocalProperties
().
get
(
"iso3166"
);
if
(
StringUtils
.
isNullOrEmpty
(
callerIso
))
return
;
// Call contacts one at a time in a random order
Map
<
ContactId
,
TransportProperties
>
remote
=
callback
.
getRemoteProperties
();
List
<
ContactId
>
contacts
=
new
ArrayList
<
ContactId
>(
remote
.
keySet
());
Collections
.
shuffle
(
contacts
);
Iterator
<
ContactId
>
it
=
contacts
.
iterator
();
while
(
it
.
hasNext
()
&&
running
)
{
ContactId
c
=
it
.
next
();
// Get the ISO 3166 code for the callee's country
TransportProperties
properties
=
remote
.
get
(
c
);
if
(
properties
==
null
)
continue
;
String
calleeIso
=
properties
.
get
(
"iso3166"
);
if
(
StringUtils
.
isNullOrEmpty
(
calleeIso
))
continue
;
// Get the callee's phone number
String
number
=
properties
.
get
(
"number"
);
if
(
StringUtils
.
isNullOrEmpty
(
number
))
continue
;
// Convert the number into direct dialling form
number
=
CountryCodes
.
translate
(
number
,
callerIso
,
calleeIso
);
if
(
number
==
null
)
continue
;
// Dial the number
try
{
if
(!
modem
.
dial
(
number
))
continue
;
}
catch
(
IOException
e
)
{
if
(
LOG
.
isLoggable
(
WARNING
))
LOG
.
log
(
WARNING
,
e
.
toString
(),
e
);
if
(
resetModem
())
continue
;
break
;
}
if
(
LOG
.
isLoggable
(
INFO
))
LOG
.
info
(
"Outgoing call connected"
);
ModemTransportConnection
conn
=
new
ModemTransportConnection
();
callback
.
outgoingConnectionCreated
(
c
,
conn
);
try
{
conn
.
waitForDisposal
();
}
catch
(
InterruptedException
e
)
{
if
(
LOG
.
isLoggable
(
WARNING
))
LOG
.
warning
(
"Interrupted while polling"
);
Thread
.
currentThread
().
interrupt
();
break
;
try
{
// Get the ISO 3166 code for the caller's country
String
callerIso
=
callback
.
getLocalProperties
().
get
(
"iso3166"
);
if
(
StringUtils
.
isNullOrEmpty
(
callerIso
))
return
;
// Call contacts one at a time in a random order
Map
<
ContactId
,
TransportProperties
>
remote
=
callback
.
getRemoteProperties
();
List
<
ContactId
>
contacts
=
new
ArrayList
<
ContactId
>(
remote
.
keySet
());
Collections
.
shuffle
(
contacts
);
Iterator
<
ContactId
>
it
=
contacts
.
iterator
();
while
(
it
.
hasNext
()
&&
running
)
{
ContactId
c
=
it
.
next
();
// Get the ISO 3166 code for the callee's country
TransportProperties
properties
=
remote
.
get
(
c
);
if
(
properties
==
null
)
continue
;
String
calleeIso
=
properties
.
get
(
"iso3166"
);
if
(
StringUtils
.
isNullOrEmpty
(
calleeIso
))
continue
;
// Get the callee's phone number
String
number
=
properties
.
get
(
"number"
);
if
(
StringUtils
.
isNullOrEmpty
(
number
))
continue
;
// Convert the number into direct dialling form
number
=
CountryCodes
.
translate
(
number
,
callerIso
,
calleeIso
);
if
(
number
==
null
)
continue
;
// Dial the number
try
{
if
(!
modem
.
dial
(
number
))
continue
;
}
catch
(
IOException
e
)
{
if
(
LOG
.
isLoggable
(
WARNING
))
LOG
.
log
(
WARNING
,
e
.
toString
(),
e
);
if
(
resetModem
())
continue
;
break
;
}
if
(
LOG
.
isLoggable
(
INFO
))
LOG
.
info
(
"Outgoing call connected"
);
ModemTransportConnection
conn
=
new
ModemTransportConnection
();
callback
.
outgoingConnectionCreated
(
c
,
conn
);
try
{
conn
.
waitForDisposal
();
}
catch
(
InterruptedException
e
)
{
if
(
LOG
.
isLoggable
(
WARNING
))
LOG
.
warning
(
"Interrupted while polling"
);
Thread
.
currentThread
().
interrupt
();
break
;
}
}
}
finally
{
polling
.
release
();
}
polling
.
release
();
}
public
DuplexTransportConnection
createConnection
(
ContactId
c
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment