Author: mladen.turk(a)jboss.com
Date: 2009-02-16 07:10:04 -0500 (Mon, 16 Feb 2009)
New Revision: 2297
Modified:
trunk/mod_cluster/native/advertise/mod_advertise.c
Log:
Bind the socket to local interface before doing join
Modified: trunk/mod_cluster/native/advertise/mod_advertise.c
===================================================================
--- trunk/mod_cluster/native/advertise/mod_advertise.c 2009-02-14 09:36:34 UTC (rev 2296)
+++ trunk/mod_cluster/native/advertise/mod_advertise.c 2009-02-16 12:10:04 UTC (rev 2297)
@@ -86,6 +86,7 @@
static apr_socket_t *ma_listen_socket = NULL;
static apr_sockaddr_t *ma_mgroup_sa = NULL;
static apr_sockaddr_t *ma_listen_sa = NULL;
+static apr_sockaddr_t *ma_niface_sa = NULL;
static server_rec *ma_server_rec = NULL;
@@ -338,9 +339,24 @@
APR_INET, port,
APR_UNSPEC, pool)) != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
- "mod_advertise: ma_group_join apr_sockaddr_info_get
failed");
+ "mod_advertise: ma_group_join apr_sockaddr_info_get(%s:%d)
failed",
+ addr, port);
return rv;
}
+ if ((rv = apr_sockaddr_info_get(&ma_listen_sa, NULL,
+ ma_mgroup_sa->family, 0,
+ APR_UNSPEC, pool)) != APR_SUCCESS) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
+ "mod_advertise: ma_group_join apr_sockaddr_info_get(0.0.0.0:0)
failed");
+ return rv;
+ }
+ if ((rv = apr_sockaddr_info_get(&ma_niface_sa, NULL,
+ ma_mgroup_sa->family, 0,
+ APR_UNSPEC, pool)) != APR_SUCCESS) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
+ "mod_advertise: ma_group_join apr_sockaddr_info_get(0.0.0.0:0)
failed");
+ return rv;
+ }
if ((rv = apr_socket_create(&ma_mgroup_socket,
ma_mgroup_sa->family,
SOCK_DGRAM,
@@ -350,8 +366,19 @@
"mod_advertise: ma_group_join apr_socket_create failed");
return rv;
}
+ if ((rv = apr_socket_opt_set(ma_mgroup_socket,
+ APR_SO_REUSEADDR, 1)) != APR_SUCCESS) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
+ "mod_advertise: ma_group_join apr_socket_opt_set
failed");
+ return rv;
+ }
+ if ((rv = apr_socket_bind(ma_mgroup_socket, ma_listen_sa)) != APR_SUCCESS) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
+ "mod_advertise: ma_group_join apr_socket_bind failed");
+ return rv;
+ }
if ((rv = apr_mcast_join(ma_mgroup_socket, ma_mgroup_sa,
- NULL, NULL)) != APR_SUCCESS) {
+ ma_niface_sa, NULL)) != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_DEBUG, rv, s,
"mod_advertise: ma_group_join apr_mcast_join failed");
if ((rv = apr_mcast_loopback(ma_mgroup_socket, 1)) != APR_SUCCESS) {