Fixes a failure to close a Socket instance.
Makes sure that Socket instances which are discarded because they are only added after the corresponding ICE Agent has moved away from the WAITING or RUNNING state are closed. This prevents a file descriptor leak, since Socket instances which are not closed (even after they are garbage collected) leave behind sockets in state CLOSE_WAIT.
This commit is contained in:
parent
e4f5534b3d
commit
568ace382b
@ -1226,10 +1226,8 @@ public class TcpHarvester
|
|||||||
if (!IceProcessingState.WAITING.equals(state)
|
if (!IceProcessingState.WAITING.equals(state)
|
||||||
&& !IceProcessingState.RUNNING.equals(state))
|
&& !IceProcessingState.RUNNING.equals(state))
|
||||||
{
|
{
|
||||||
logger.info(
|
throw new IllegalStateException(
|
||||||
"Not adding a socket to an ICE agent with state "
|
"The associated Agent is in state " + state);
|
||||||
+ state);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Socket to add to the candidate
|
// Socket to add to the candidate
|
||||||
@ -1433,19 +1431,11 @@ public class TcpHarvester
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException ioe)
|
catch (IOException | StunException | IllegalStateException e)
|
||||||
{
|
{
|
||||||
logger.info(
|
logger.info(
|
||||||
"Failed to handle TCP socket "
|
"Failed to handle TCP socket "
|
||||||
+ channel.channel.socket() + ": " + ioe);
|
+ channel.channel.socket() + ": " + e.getMessage());
|
||||||
key.cancel();
|
|
||||||
closeNoExceptions(channel.channel);
|
|
||||||
}
|
|
||||||
catch (StunException se)
|
|
||||||
{
|
|
||||||
logger.info(
|
|
||||||
"Failed to handle TCP socket "
|
|
||||||
+ channel.channel.socket() + ": " + se);
|
|
||||||
key.cancel();
|
key.cancel();
|
||||||
closeNoExceptions(channel.channel);
|
closeNoExceptions(channel.channel);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user