diff options
author | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2014-05-07 14:21:59 +0300 |
---|---|---|
committer | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2014-05-07 14:21:59 +0300 |
commit | 4d0b635908225260f4029882d63fada48a96e8c6 (patch) | |
tree | 08748f35f8f5187fb735f06be74bf5c71b45a815 /src/net/java/sip/communicator/service/protocol/media | |
parent | 979d99145ee25600a548a05e4c572b68a1a5a3ae (diff) | |
download | jitsi-4d0b635908225260f4029882d63fada48a96e8c6.zip jitsi-4d0b635908225260f4029882d63fada48a96e8c6.tar.gz jitsi-4d0b635908225260f4029882d63fada48a96e8c6.tar.bz2 |
Fixes an issue in the allocation of ports which causes a portion of a user-specified port range to be utilized. Reported by Emil Ivov.
Diffstat (limited to 'src/net/java/sip/communicator/service/protocol/media')
-rw-r--r-- | src/net/java/sip/communicator/service/protocol/media/TransportManager.java | 77 |
1 files changed, 41 insertions, 36 deletions
diff --git a/src/net/java/sip/communicator/service/protocol/media/TransportManager.java b/src/net/java/sip/communicator/service/protocol/media/TransportManager.java index 419a001..ae9a6d3 100644 --- a/src/net/java/sip/communicator/service/protocol/media/TransportManager.java +++ b/src/net/java/sip/communicator/service/protocol/media/TransportManager.java @@ -42,7 +42,8 @@ public abstract class TransportManager<U extends MediaAwareCallPeer<?, ?, ?>> * Initialized by {@link #initializePortNumbers()}.
* </p>
*/
- private static PortTracker defaultPortTracker = new PortTracker(5000, 6000);
+ private static final PortTracker defaultPortTracker
+ = new PortTracker(5000, 6000);
/**
* The port tracker that we should use when binding video media streams.
@@ -51,25 +52,25 @@ public abstract class TransportManager<U extends MediaAwareCallPeer<?, ?, ?>> * necessary properties are set.
* </p>
*/
- private static PortTracker videoPortTracker = null;
+ private static PortTracker videoPortTracker;
/**
* The port tracker that we should use when binding data channels.
* <p>
* Potentially initialized by {@link #initializePortNumbers()} if the
- * necessary properties are set
+ * necessary properties are set.
* </p>
*/
- private static PortTracker dataChannelPortTracker = null;
+ private static PortTracker dataPortTracker;
/**
* The port tracker that we should use when binding data media streams.
* <p>
* Potentially initialized by {@link #initializePortNumbers()} if the
- * necessary properties are set
+ * necessary properties are set.
* </p>
*/
- private static PortTracker audioPortTracker = null;
+ private static PortTracker audioPortTracker;
/**
* RTP audio DSCP configuration property name.
@@ -281,70 +282,72 @@ public abstract class TransportManager<U extends MediaAwareCallPeer<?, ?, ?>> }
/**
- * (Re)Sets the all the port allocators to reflect current values specified
- * in the <tt>ConfigurationService</tt>. Calling this method may very well
- * result in creating new port allocators or destroying existing ones.
+ * Tries to set the ranges of the <tt>PortTracker</tt>s (e.g. default,
+ * audio, video, data channel) to the values specified in the
+ * <tt>ConfigurationService</tt>.
*/
- protected static void initializePortNumbers()
+ protected synchronized static void initializePortNumbers()
{
//try the default tracker first
ConfigurationService cfg
= ProtocolMediaActivator.getConfigurationService();
- String minPortNumberStr
+ String minPort
= cfg.getString(
OperationSetBasicTelephony
.MIN_MEDIA_PORT_NUMBER_PROPERTY_NAME);
- String maxPortNumberStr
+ String maxPort
= cfg.getString(
OperationSetBasicTelephony
.MAX_MEDIA_PORT_NUMBER_PROPERTY_NAME);
- //try to send the specified range. If there's no specified range in
- //configuration, we'll just leave the tracker as it is: [5000 to 6000]
- defaultPortTracker.tryRange(minPortNumberStr, maxPortNumberStr);
+ //Try the specified range; otherwise, leave the tracker as it is:
+ //[5000, 6000].
+ defaultPortTracker.tryRange(minPort, maxPort);
//try the VIDEO tracker
- minPortNumberStr
+ minPort
= cfg.getString(
OperationSetBasicTelephony
.MIN_VIDEO_PORT_NUMBER_PROPERTY_NAME);
- maxPortNumberStr
+ maxPort
= cfg.getString(
OperationSetBasicTelephony
.MAX_VIDEO_PORT_NUMBER_PROPERTY_NAME);
- //try to send the specified range. If there's no specified range in
- //configuration, we'll just leave this tracker to null
- videoPortTracker
- = PortTracker.createTracker(minPortNumberStr, maxPortNumberStr);
+ //Try the specified range; otherwise, leave the tracker to null.
+ if (videoPortTracker == null)
+ videoPortTracker = PortTracker.createTracker(minPort, maxPort);
+ else
+ videoPortTracker.tryRange(minPort, maxPort);
//try the AUDIO tracker
- minPortNumberStr
+ minPort
= cfg.getString(
OperationSetBasicTelephony
.MIN_AUDIO_PORT_NUMBER_PROPERTY_NAME);
- maxPortNumberStr
+ maxPort
= cfg.getString(
OperationSetBasicTelephony
.MAX_AUDIO_PORT_NUMBER_PROPERTY_NAME);
- //try to send the specified range. If there's no specified range in
- //configuration, we'll just leave this tracker to null
- audioPortTracker
- = PortTracker.createTracker(minPortNumberStr, maxPortNumberStr);
+ //Try the specified range; otherwise, leave the tracker to null.
+ if (audioPortTracker == null)
+ audioPortTracker = PortTracker.createTracker(minPort, maxPort);
+ else
+ audioPortTracker.tryRange(minPort, maxPort);
//try the DATA CHANNEL tracker
- minPortNumberStr
+ minPort
= cfg.getString(
OperationSetBasicTelephony
.MIN_DATA_CHANNEL_PORT_NUMBER_PROPERTY_NAME);
- maxPortNumberStr
+ maxPort
= cfg.getString(
OperationSetBasicTelephony
.MAX_DATA_CHANNEL_PORT_NUMBER_PROPERTY_NAME);
-
- //try to send the specified range. If there's no specified range in
- //configuration, we'll just leave this tracker to null
- dataChannelPortTracker
- = PortTracker.createTracker(minPortNumberStr, maxPortNumberStr);
+ //Try the specified range; otherwise, leave the tracker to null.
+ if (dataPortTracker == null)
+ dataPortTracker = PortTracker.createTracker(minPort, maxPort);
+ else
+ dataPortTracker.tryRange(minPort, maxPort);
}
/**
@@ -594,11 +597,13 @@ public abstract class TransportManager<U extends MediaAwareCallPeer<?, ?, ?>> case AUDIO:
if (audioPortTracker != null)
return audioPortTracker;
- break;
+ else
+ break;
case VIDEO:
if (videoPortTracker != null)
return videoPortTracker;
- break;
+ else
+ break;
}
return defaultPortTracker;
|