--------------------- PatchSet 10183 Date: 2007/11/30 16:37:01 Author: adri Branch: store_copy Tag: (none) Log: revert xinet_ntoa optimisation/use; thats not for this branch. Members: src/http.c:1.63.2.2->1.63.2.3 src/peer_sourcehash.c:1.3.48.1->1.3.48.2 src/tools.c:1.62.2.1->1.62.2.2 Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/http.c,v retrieving revision 1.63.2.2 retrieving revision 1.63.2.3 diff -u -r1.63.2.2 -r1.63.2.3 --- squid/src/http.c 30 Nov 2007 15:55:21 -0000 1.63.2.2 +++ squid/src/http.c 30 Nov 2007 16:37:01 -0000 1.63.2.3 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.63.2.2 2007/11/30 15:55:21 adri Exp $ + * $Id: http.c,v 1.63.2.3 2007/11/30 16:37:01 adri Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -1220,7 +1220,7 @@ strFwd = httpHeaderGetList(hdr_in, HDR_X_FORWARDED_FOR); strListAdd(&strFwd, (((orig_request->client_addr.s_addr != no_addr.s_addr) && opt_forwarded_for) ? - xinet_ntoa(orig_request->client_addr) : "unknown"), ','); + inet_ntoa(orig_request->client_addr) : "unknown"), ','); httpHeaderPutStr(hdr_out, HDR_X_FORWARDED_FOR, strBuf(strFwd)); stringClean(&strFwd); } Index: squid/src/peer_sourcehash.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/peer_sourcehash.c,v retrieving revision 1.3.48.1 retrieving revision 1.3.48.2 diff -u -r1.3.48.1 -r1.3.48.2 --- squid/src/peer_sourcehash.c 30 Nov 2007 15:55:21 -0000 1.3.48.1 +++ squid/src/peer_sourcehash.c 30 Nov 2007 16:37:01 -0000 1.3.48.2 @@ -1,6 +1,6 @@ /* - * $Id: peer_sourcehash.c,v 1.3.48.1 2007/11/30 15:55:21 adri Exp $ + * $Id: peer_sourcehash.c,v 1.3.48.2 2007/11/30 16:37:01 adri Exp $ * * DEBUG: section 44 Peer user hash based selection * AUTHOR: Henrik Nordstrom @@ -134,9 +134,9 @@ unsigned int combined_hash; double score; double high_score = 0; - const char *key = NULL; + char *key = NULL; - key = xinet_ntoa(request->client_addr); + key = inet_ntoa(request->client_addr); /* calculate hash key */ debug(39, 2) ("peerSourceHashSelectParent: Calculating hash for %s\n", key); Index: squid/src/tools.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/tools.c,v retrieving revision 1.62.2.1 retrieving revision 1.62.2.2 diff -u -r1.62.2.1 -r1.62.2.2 --- squid/src/tools.c 30 Nov 2007 15:55:21 -0000 1.62.2.1 +++ squid/src/tools.c 30 Nov 2007 16:37:01 -0000 1.62.2.2 @@ -1,6 +1,6 @@ /* - * $Id: tools.c,v 1.62.2.1 2007/11/30 15:55:21 adri Exp $ + * $Id: tools.c,v 1.62.2.2 2007/11/30 16:37:01 adri Exp $ * * DEBUG: section 21 Misc Functions * AUTHOR: Harvest Derived @@ -1403,79 +1403,5 @@ const char * xinet_ntoa(const struct in_addr addr) { - static char buf[32]; - char *s = buf + 30; - unsigned char a; - unsigned int ad = ntohl(addr.s_addr); - s[31] = '\0'; - - a = (ad) & 0xff; - do { - *(s--) = (a % 10) + '0'; - a /= 10; - } while (a > 0); - *(s--) = '.'; - - a = (ad >> 8) & 0xff; - do { - *(s--) = (a % 10) + '0'; - a /= 10; - } while (a > 0); - *(s--) = '.'; - - a = (ad >> 16) & 0xff; - do { - *(s--) = (a % 10) + '0'; - a /= 10; - } while (a > 0); - *(s--) = '.'; - - a = (ad >> 24) & 0xff; - do { - *(s--) = (a % 10) + '0'; - a /= 10; - } while (a > 0); - - return s + 1; - -} - -/** - * Parse a socket address (host:port), fill the given sockaddr_in structure - * Returns FALSE on failure, TRUE on success - * Destroys s - */ -int -parse_sockaddr(char *s, struct sockaddr_in *addr) -{ - char *host, *tmp, *colon; - unsigned short port = 0; - const struct hostent *hp; - - host = NULL; - port = 0; - if ((colon = strchr(s, ':'))) { - /* host:port */ - host = s; - *colon = '\0'; - port = xatos(colon + 1); - if (0 == port) - return FALSE; - } else if ((port = strtol(s, &tmp, 10)), !*tmp) { - /* port */ - } else { - host = s; - port = 0; - } - addr->sin_port = htons(port); - if (NULL == host) - addr->sin_addr = any_addr; - else if (1 == safe_inet_addr(host, &addr->sin_addr)) - (void) 0; - else if ((hp = gethostbyname(host))) /* dont use ipcache */ - addr->sin_addr = inaddrFromHostent(hp); - else - return FALSE; - addr->sin_family = AF_INET; - return TRUE; + return inet_ntoa(addr); }