Skip to content
Snippets Groups Projects
Commit 096b349f authored by Lyubomir Marinov's avatar Lyubomir Marinov
Browse files

Fixes an issue which could cause CPU starvation while receiving from MultiplexingDatagramSocket.

parent a9d5f971
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -21,15 +21,18 @@
public class RTPConnectorUDPInputStream
extends RTPConnectorInputStream
{
/**
* UDP socket used to receive data.
* The indicator which determine whether
* {@link DatagramSocket#setReceiveBufferSize(int)} has been invoked on
* {@link #socket}.
*/
private final DatagramSocket socket;
private boolean setReceiveBufferSize = false;
/**
* Receive size configured flag.
* UDP socket used to receive data.
*/
private boolean receivedSizeFlag = false;
private final DatagramSocket socket;
/**
* Initializes a new <tt>RTPConnectorInputStream</tt> which is to receive
......@@ -104,16 +107,17 @@ protected void doLogPacket(DatagramPacket p)
protected void receivePacket(DatagramPacket p)
throws IOException
{
if(!receivedSizeFlag)
if (!setReceiveBufferSize)
{
receivedSizeFlag = true;
setReceiveBufferSize = true;
try
{
socket.setReceiveBufferSize(65535);
}
catch(Throwable t)
catch (Throwable t)
{
if (t instanceof ThreadDeath)
throw (ThreadDeath) t;
}
}
socket.receive(p);
......
......@@ -302,6 +302,7 @@ public int receive(byte[] buf, int off, int len, int waitMillis)
}
if (interrupted)
Thread.currentThread().interrupt();
return received;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment