Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NetworkedGraphicsMV3500
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Savage
NetworkedGraphicsMV3500
Commits
b02830aa
Commit
b02830aa
authored
5 years ago
by
Terry D. Norbraten
Browse files
Options
Downloads
Patches
Plain Diff
let the finally block handle leaving group and closing sockets
parent
c1b0ef5a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/edu/nps/moves/dis7/utilities/DisThreadedNetIF.java
+18
-22
18 additions, 22 deletions
src/edu/nps/moves/dis7/utilities/DisThreadedNetIF.java
with
18 additions
and
22 deletions
src/edu/nps/moves/dis7/utilities/DisThreadedNetIF.java
+
18
−
22
View file @
b02830aa
...
...
@@ -221,10 +221,15 @@ public class DisThreadedNetIF
System
.
err
.
println
(
"Exception in DISThreadedNetIF receive thread: "
+
ex
.
getLocalizedMessage
());
System
.
err
.
println
(
"Retrying in 1 second"
);
}
finally
{
if
(
rsocket
!=
null
)
{
rsocket
.
close
();
rsocket
=
null
;
}
if
(
rsocket
!=
null
&&
!
rsocket
.
isClosed
())
{
try
{
rsocket
.
leaveGroup
(
group
,
ni
);
}
catch
(
IOException
ex
)
{
Logger
.
getLogger
(
DisThreadedNetIF
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
rsocket
.
close
();
rsocket
=
null
;
}
}
if
(!
killed
)
sleep
(
250
);
...
...
@@ -263,10 +268,15 @@ public class DisThreadedNetIF
System
.
err
.
println
(
"Exception in DISThreadedNetIF send thread: "
+
ex
.
getLocalizedMessage
());
System
.
err
.
println
(
"Retrying in 1 second"
);
}
finally
{
if
(
ssocket
!=
null
)
{
ssocket
.
close
();
ssocket
=
null
;
}
if
(
ssocket
!=
null
&&
!
ssocket
.
isClosed
())
{
try
{
ssocket
.
leaveGroup
(
group
,
ni
);
}
catch
(
IOException
ex
)
{
Logger
.
getLogger
(
DisThreadedNetIF
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
ssocket
.
close
();
ssocket
=
null
;
}
}
if
(!
killed
)
sleep
(
250
);
...
...
@@ -298,20 +308,6 @@ public class DisThreadedNetIF
public
void
kill
()
{
killed
=
true
;
try
{
if
(
ssocket
!=
null
&&
!
ssocket
.
isClosed
())
{
ssocket
.
leaveGroup
(
group
,
ni
);
ssocket
.
close
();
ssocket
=
null
;
}
if
(
rsocket
!=
null
&&
!
rsocket
.
isClosed
())
{
rsocket
.
leaveGroup
(
group
,
ni
);
rsocket
.
close
();
rsocket
=
null
;
}
}
catch
(
IOException
ex
)
{
Logger
.
getLogger
(
DisThreadedNetIF
.
class
.
getName
()).
log
(
Level
.
SEVERE
,
null
,
ex
);
}
}
private
void
sleep
(
long
ms
)
...
...
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