Author: markt
Date: Thu Jun 4 14:12:01 2009
New Revision: 781743
URL: http://svn.apache.org/viewvc?rev=781743&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=43641
Use of bind attribute for membership element breaks multicast. (rjung)
Modified:
tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/mcast/McastServiceImpl.java
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/McastServiceImpl.java
tomcat/container/tc5.5.x/webapps/docs/changelog.xml
Modified:
tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/mcast/McastServiceImpl.java
URL:
http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/mcast/McastServiceImpl.java?rev=781743&r1=781742&r2=781743&view=diff
==============================================================================
---
tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/mcast/McastServiceImpl.java
(original)
+++
tomcat/container/tc5.5.x/modules/cluster/src/share/org/apache/catalina/cluster/mcast/McastServiceImpl.java
Thu Jun 4 14:12:01 2009
@@ -18,10 +18,12 @@
package org.apache.catalina.cluster.mcast;
-import java.net.MulticastSocket;
import java.io.IOException;
-import java.net.InetAddress ;
+import java.net.BindException;
import java.net.DatagramPacket;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.MulticastSocket;
import java.net.SocketTimeoutException;
import org.apache.catalina.cluster.MembershipListener;
@@ -165,10 +167,23 @@
}
protected void setupSocket() throws IOException {
- if (mcastBindAddress != null) socket = new MulticastSocket(new
java.net.
- InetSocketAddress(mcastBindAddress, port));
- else socket = new MulticastSocket(port);
- socket.setLoopbackMode(false); //hint that we don't need loop back
messages
+ if (mcastBindAddress != null) {
+ try {
+ log.info("Attempting to bind the multicast socket to
"+address+":"+port);
+ socket = new MulticastSocket(new
InetSocketAddress(address,port));
+ } catch (BindException e) {
+ /*
+ * On some plattforms (e.g. Linux) it is not possible to bind
+ * to the multicast address. In this case only bind to the
+ * port.
+ */
+ log.info("Binding to multicast address, failed. Binding to
port only.");
+ socket = new MulticastSocket(port);
+ }
+ } else {
+ socket = new MulticastSocket(port);
+ }
+ socket.setLoopbackMode(false); //hint that we don't need loop back
messages
if (mcastBindAddress != null) {
if(log.isInfoEnabled())
log.info("Setting multihome multicast interface to:" +
Modified:
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/McastServiceImpl.java
URL:
http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/McastServiceImpl.java?rev=781743&r1=781742&r2=781743&view=diff
==============================================================================
---
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/McastServiceImpl.java
(original)
+++
tomcat/container/tc5.5.x/modules/groupcom/src/share/org/apache/catalina/tribes/membership/McastServiceImpl.java
Thu Jun 4 14:12:01 2009
@@ -19,16 +19,17 @@
import java.io.IOException;
+import java.net.BindException;
import java.net.DatagramPacket;
import java.net.InetAddress;
+import java.net.InetSocketAddress;
import java.net.MulticastSocket;
+import java.net.SocketTimeoutException;
import org.apache.catalina.tribes.MembershipListener;
import java.util.Arrays;
-import java.net.SocketTimeoutException;
import org.apache.catalina.tribes.Member;
import org.apache.catalina.tribes.Channel;
-import java.net.InetSocketAddress;
/**
* A <b>membership</b> implementation using simple multicast.
@@ -162,8 +163,23 @@
}
protected void setupSocket() throws IOException {
- if (mcastBindAddress != null) socket = new MulticastSocket(new
InetSocketAddress(mcastBindAddress, port));
- else socket = new MulticastSocket(port);
+ if (mcastBindAddress != null) {
+ try {
+ log.info("Attempting to bind the multicast socket to
"+address+":"+port);
+ socket = new MulticastSocket(new
InetSocketAddress(address,port));
+ } catch (BindException e) {
+ /*
+ * On some plattforms (e.g. Linux) it is not possible to bind
+ * to the multicast address. In this case only bind to the
+ * port.
+ */
+ log.info("Binding to multicast address, failed. Binding to
port only.");
+ socket = new MulticastSocket(port);
+ }
+ } else {
+ socket = new MulticastSocket(port);
+ }
+ socket.setLoopbackMode(false); //hint that we don't need loop back
messages
if (mcastBindAddress != null) {
if(log.isInfoEnabled())
log.info("Setting multihome multicast interface to:"
+mcastBindAddress);
Modified: tomcat/container/tc5.5.x/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/webapps/docs/changelog.xml?rev=781743&r1=781742&r2=781743&view=diff
==============================================================================
--- tomcat/container/tc5.5.x/webapps/docs/changelog.xml (original)
+++ tomcat/container/tc5.5.x/webapps/docs/changelog.xml Thu Jun 4 14:12:01 2009
@@ -157,6 +157,10 @@
Handle situation session ID rewriting on fail-over with parallel
requests
from the same client. (pero)
</fix>
+ <fix>
+ <bug>43641</bug>: Use of bind attribute for membership element breaks
+ multicast. (rjung)
+ </fix>
</changelog>
</subsection>
<subsection name="Webapps">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]