Revision: 14938 Author: adrian.chadd Date: Fri Jul 22 20:53:26 2011 Log: Add a sqaddr_t "net" to the netdb entry.
This will be used by an update to the netdb exchange format to allow ipv4/ipv6 database exchanges. http://code.google.com/p/lusca-cache/source/detail?r=14938 Modified: /playpen/LUSCA_HEAD_ipv6/src/net_db.c /playpen/LUSCA_HEAD_ipv6/src/structs.h ======================================= --- /playpen/LUSCA_HEAD_ipv6/src/net_db.c Thu Jul 14 09:47:54 2011 +++ /playpen/LUSCA_HEAD_ipv6/src/net_db.c Fri Jul 22 20:53:26 2011 @@ -87,16 +87,14 @@ netdbHashInsert(netdbEntry * n, sqaddr_t *addr) { char sbuf[MAX_IPSTRLEN]; - sqaddr_t a; - - sqinet_init(&a); - networkFromInaddr(&a, addr); - (void) sqinet_ntoa(&a, sbuf, MAX_IPSTRLEN, SQADDR_NO_BRACKET_V6); + + sqinet_init(&n->net); + networkFromInaddr(&n->net, addr); + (void) sqinet_ntoa(&n->net, sbuf, MAX_IPSTRLEN, SQADDR_NO_BRACKET_V6); xstrncpy(n->network, sbuf, MAX_IPSTRLEN); n->hash.key = n->network; assert(hash_lookup(addr_table, n->network) == NULL); hash_join(addr_table, &n->hash); - sqinet_done(&a); } static void @@ -166,6 +164,7 @@ n->n_peers_alloc = 0; if (n->link_count == 0) { netdbHashDelete(n->network); + sqinet_done(&n->net); memPoolFree(pool_netdb_entry, n); } } @@ -233,6 +232,7 @@ netdbPurgeLRU(); if ((n = netdbLookupAddr(addr)) == NULL) { n = memPoolAlloc(pool_netdb_entry); + sqinet_init(&n->net); netdbHashInsert(n, addr); } return n; @@ -518,6 +518,11 @@ N.last_use_time = (time_t) atoi(q); n = memPoolAlloc(pool_netdb_entry); xmemcpy(n, &N, sizeof(netdbEntry)); + /* + * XXX this is ugly, but setup the net variable -after- + * XXX the struct has been copied in-place. ew. + */ + sqinet_init(&n->net); netdbHashInsert(n, &addr); while ((q = strtok(NULL, w_space)) != NULL) { if (netdbLookupHost(q) != NULL) /* no dups! */ @@ -550,6 +555,7 @@ { netdbEntry *n = data; safe_free(n->peers); + sqinet_done(&n->net); memPoolFree(pool_netdb_entry, n); } ======================================= --- /playpen/LUSCA_HEAD_ipv6/src/structs.h Thu Jul 14 09:47:54 2011 +++ /playpen/LUSCA_HEAD_ipv6/src/structs.h Fri Jul 22 20:53:26 2011 @@ -1320,6 +1320,7 @@ struct _netdbEntry { hash_link hash; /* must be first */ + sqaddr_t net; char network[MAX_IPSTRLEN]; int pings_sent; int pings_recv; -- You received this message because you are subscribed to the Google Groups "lusca-commit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/lusca-commit?hl=en.
