[Patch 3/3] tabled: drop addr_af

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This flag was is a useless duplication and a fiction prompted by
getaddrinfo(). In reality it's not useful even if we decide to run
CLD over DCCP.

Signed-off-by: Pete Zaitcev <zaitcev@xxxxxxxxxx>

---
 server/storage.c |    8 ++++----
 server/tabled.h  |    3 +--
 2 files changed, 5 insertions(+), 6 deletions(-)

commit 7b1efec72048557b1b51d07a95073dbe25cf08d1
Author: Master <zaitcev@xxxxxxxxxxxxxxxxxx>
Date:   Tue Dec 15 21:47:48 2009 -0700

    Drop af flag, not needed.

diff --git a/server/storage.c b/server/storage.c
index cc7066f..8298e60 100644
--- a/server/storage.c
+++ b/server/storage.c
@@ -44,10 +44,10 @@ static int stor_new_stc(struct storage_node *stn, struct st_client **stcp)
 	struct sockaddr_in6 *a6;
 	unsigned short port;
 
-	if (stn->addr_af == AF_INET) {
+	if (stn->addr.sin6_family == AF_INET) {
 		a4 = (struct sockaddr_in *) &stn->addr;
 		port = ntohs(a4->sin_port);
-	} else if (stn->addr_af == AF_INET6) {
+	} else if (stn->addr.sin6_family == AF_INET6) {
 		a6 = &stn->addr;
 		port = ntohs(a6->sin6_port);
 	} else {
@@ -419,9 +419,9 @@ static int stor_add_node_addr(struct storage_node *sn,
 		if (res->ai_addrlen > ADDRSIZE)		/* should not happen */
 			continue;
 
-		memcpy(&sn->addr, res->ai_addr, res->ai_addrlen);
-		sn->addr_af = res->ai_family;
 		sn->alen = res->ai_addrlen;
+		memcpy(&sn->addr, res->ai_addr, sn->alen);
+		sn->addr.sin6_family = res->ai_family;
 
 		/* Use just the first address for now. */
 		freeaddrinfo(res0);
diff --git a/server/tabled.h b/server/tabled.h
index 51bfd44..290edaf 100644
--- a/server/tabled.h
+++ b/server/tabled.h
@@ -36,7 +36,7 @@
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
 #endif
 
-#define ADDRSIZE	24	/* Enough for IPv6, including port. */
+#define ADDRSIZE	(sizeof(struct sockaddr_in6))	/* enough for v4 & v6 */
 
 enum {
 	TABLED_PGSZ_INODE	= 4096,
@@ -96,7 +96,6 @@ struct storage_node {
 	time_t			last_up;
 
 	unsigned		alen;
-	int			addr_af;
 	struct sockaddr_in6	addr;
 	char *hostname;		/* Only used because stc_new is overly smart. */
 
--
To unsubscribe from this list: send the line "unsubscribe hail-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Fedora Clound]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux