Fix length of newly created buffers in RawPacket. Fix NPE when we receive response for client transaction which has already expired. Lower the size of the newly created buffers used to receive udp packets.

cusax-fix
Damian Minkov 16 years ago
parent f6113a5000
commit a9addae823

@ -27,10 +27,15 @@ public class RTPConnectorInputStream
*/
private static final Object[] EMPTY_CONTROLS = new Object[0];
/**
* The size of the buffers receiving packets coming from network.
*/
private static final int PACKET_RECEIVE_BUFFER = 4000;
/**
* Packet receive buffer
*/
private final byte[] buffer = new byte[65535];
private final byte[] buffer = new byte[PACKET_RECEIVE_BUFFER];
/**
* Whether this stream is closed. Used to control the termination of worker
@ -222,7 +227,8 @@ public void run()
{
while (!closed)
{
DatagramPacket p = new DatagramPacket(buffer, 0, 65535);
DatagramPacket p = new DatagramPacket(
buffer, 0, PACKET_RECEIVE_BUFFER);
try
{

@ -330,7 +330,8 @@ public void setCsrcList(long[] newCsrcList)
| newCsrcCount);
this.buffer = newBuffer;
this.length = newBuffer.length - offset;
this.length = payloadOffsetForNewBuff + oldBuffer.length
- payloadOffsetForOldBuff - offset;
}
/**
@ -582,9 +583,10 @@ public void addExtension(byte[] extBuff, int newExtensionLen)
//now copy the payload
System.arraycopy(buffer, bufferOffset,
newBuffer, newBufferOffset, getPayloadLength());
newBufferOffset += getPayloadLength();
buffer = newBuffer;
this.length = newBuffLen - offset;
this.length = newBufferOffset - offset;
}
/**

@ -656,6 +656,12 @@ public void processResponse(ResponseEvent event)
+ event.getResponse().getStatusCode()
+ " " + event.getResponse().getReasonPhrase());
if(transaction == null)
{
logger.warn("Transaction is null, probably already expired!");
return;
}
ProtocolProviderServiceSipImpl service
= getServiceData(transaction);
if (service != null)

Loading…
Cancel
Save