summaryrefslogtreecommitdiffstats
path: root/transport/socket/src/socket.c
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2010-01-22 03:02:32 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-01-22 05:34:35 -0800
commita116e5b3ef2d4fbb57a5690a01368ec7aa0942aa (patch)
tree57fa71374cc7f2ff7660bbcd970f6ae312276eaf /transport/socket/src/socket.c
parentab8cabcd30bbb5dde4cb8a35d4fd88136994f526 (diff)
transport/socket: use appropriate address family macro when address family is inet-sdp.
- sa_family should be set to AF_INET_SDP only during call to socket system call. For all other calls, sa_family should be AF_INET. Signed-off-by: Raghavendra G <raghavendra@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 561 (with address family set to 'inet-sdp', transport/socket doesn't work correctly) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=561
Diffstat (limited to 'transport/socket/src/socket.c')
-rw-r--r--transport/socket/src/socket.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/transport/socket/src/socket.c b/transport/socket/src/socket.c
index 28baa67a5b4..151ce3c9350 100644
--- a/transport/socket/src/socket.c
+++ b/transport/socket/src/socket.c
@@ -971,6 +971,7 @@ socket_connect (transport_t *this)
struct sockaddr_storage sockaddr = {0, };
socklen_t sockaddr_len = 0;
glusterfs_ctx_t *ctx = NULL;
+ sa_family_t sa_family = {0, };
priv = this->private;
ctx = this->xl->ctx;
@@ -994,6 +995,11 @@ socket_connect (transport_t *this)
goto err;
}
+ ret = client_fill_address_family (this, &sa_family);
+ if (ret == -1) {
+ goto err;
+ }
+
ret = socket_client_get_remote_sockaddr (this, SA (&sockaddr),
&sockaddr_len);
if (ret == -1) {
@@ -1012,9 +1018,7 @@ socket_connect (transport_t *this)
memcpy (&this->peerinfo.sockaddr, &sockaddr, sockaddr_len);
this->peerinfo.sockaddr_len = sockaddr_len;
- priv->sock = socket (SA (&sockaddr)->sa_family,
- SOCK_STREAM, 0);
-
+ priv->sock = socket (sa_family, SOCK_STREAM, 0);
if (priv->sock == -1) {
gf_log (this->xl->name, GF_LOG_ERROR,
"socket creation failed (%s)",
@@ -1118,6 +1122,7 @@ socket_listen (transport_t *this)
socklen_t sockaddr_len;
peer_info_t *myinfo = NULL;
glusterfs_ctx_t *ctx = NULL;
+ sa_family_t sa_family = {0, };
priv = this->private;
myinfo = &this->myinfo;
@@ -1135,9 +1140,13 @@ socket_listen (transport_t *this)
return ret;
}
+ ret = server_fill_address_family (this, &sa_family);
+ if (ret == -1) {
+ return ret;
+ }
+
ret = socket_server_get_local_sockaddr (this, SA (&sockaddr),
&sockaddr_len);
-
if (ret == -1) {
return ret;
}
@@ -1153,8 +1162,7 @@ socket_listen (transport_t *this)
memcpy (&myinfo->sockaddr, &sockaddr, sockaddr_len);
myinfo->sockaddr_len = sockaddr_len;
- priv->sock = socket (SA (&sockaddr)->sa_family,
- SOCK_STREAM, 0);
+ priv->sock = socket (sa_family, SOCK_STREAM, 0);
if (priv->sock == -1) {
gf_log (this->xl->name, GF_LOG_ERROR,