# HG changeset patch # User Claus Gittinger # Date 1058181040 -7200 # Node ID 03afdf3f895ed6ce3eacefe0474d8f71d3c4d7d8 # Parent 150e61c7bd1011f069cda7f20e3f4acbd09addbe addrCache and nameCache must be separate for ip and ipV6 diff -r 150e61c7bd10 -r 03afdf3f895e IPSocketAddress.st --- a/IPSocketAddress.st Mon Jul 14 07:27:47 2003 +0200 +++ b/IPSocketAddress.st Mon Jul 14 13:10:40 2003 +0200 @@ -14,11 +14,18 @@ SocketAddress variableByteSubclass:#IPSocketAddress instanceVariableNames:'' - classVariableNames:'NameCache AddrCache' + classVariableNames:'' poolDictionaries:'' category:'OS-Sockets' ! +IPSocketAddress class instanceVariableNames:'addrCache nameCache' + +" + No other class instance variables are inherited by this class. +" +! + !IPSocketAddress class methodsFor:'documentation'! copyright @@ -75,9 +82,7 @@ ^ super hostName:name serviceName:portNrOrName type:socketTypeSymbol ]. - AddrCache notNil ifTrue:[ - addrBytes := AddrCache at:name ifAbsent:nil. - ]. + addrBytes := self addressCacheAt:name. addrBytes notNil ifTrue:[ sa := self hostAddress:addrBytes. portNrOrName notNil ifTrue:[ @@ -86,10 +91,7 @@ ] ifFalse:[ sa := super hostName:name serviceName:portNrOrName type:socketTypeSymbol. - (AddrCache isNil or:[AddrCache size > 30]) ifTrue:[ - AddrCache := Dictionary new - ]. - AddrCache at:name put:(sa hostAddress). + self addressCacheAt:name put:(sa hostAddress). ]. ^ sa @@ -138,14 +140,48 @@ ^ #[0 0 0 0] ! ! -!IPSocketAddress class methodsFor:'misc'! +!IPSocketAddress class methodsFor:'caching'! + +addressCacheAt:aHostName + addrCache notNil ifTrue:[ + ^ addrCache at:aHostName ifAbsent:nil. + ]. + ^ nil +! + +addressCacheAt:aName put:aHostAddress + (addrCache isNil or:[addrCache size > 30]) ifTrue:[ + addrCache := Dictionary new. + ]. + + addrCache at:aName put:aHostAddress. +! flushAddressCache - AddrCache := nil + addrCache := nil " self flushAddressCache " +! + +flushNameCache + nameCache := Dictionary new. +! + +nameCacheAt:aHostAddress + nameCache notNil ifTrue:[ + ^ nameCache at:aHostAddress ifAbsent:nil. + ]. + ^ nil +! + +nameCacheAt:aHostAddress put:aName + (nameCache isNil or:[nameCache size > 30]) ifTrue:[ + nameCache := Dictionary new. + ]. + + nameCache at:aHostAddress put:aName. ! ! !IPSocketAddress class methodsFor:'queries'! @@ -226,19 +262,16 @@ !IPSocketAddress methodsFor:'queries'! hostName - |name| + |addr name| - NameCache notNil ifTrue:[ - name := NameCache at:(self hostAddress) ifAbsent:nil. - name notNil ifTrue:[^ name]. - ]. + addr := self hostAddress. + + name := self class nameCacheAt:addr. + name notNil ifTrue:[^ name]. name := super hostName. name notNil ifTrue:[ - (NameCache isNil or:[NameCache size > 30]) ifTrue:[ - NameCache := Dictionary new - ]. - NameCache at:(self hostAddress) put:name. + self class nameCacheAt:addr put:name. ]. ^ name ! ! @@ -246,5 +279,5 @@ !IPSocketAddress class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic2/IPSocketAddress.st,v 1.21 2003-07-09 15:31:33 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic2/IPSocketAddress.st,v 1.22 2003-07-14 11:10:40 cg Exp $' ! ! diff -r 150e61c7bd10 -r 03afdf3f895e SocketAddress.st --- a/SocketAddress.st Mon Jul 14 07:27:47 2003 +0200 +++ b/SocketAddress.st Mon Jul 14 13:10:40 2003 +0200 @@ -170,7 +170,7 @@ domainCode "answer the numerical domain code used in socket addresses" - ^ OperatingSystem socketAccessor domainCodeOf:self domainSymbol + ^ OperatingSystem socketAccessor domainCodeOf:(self domainSymbol) ! domainCodeFromName:aNameSymbol @@ -344,6 +344,8 @@ ^ SocketAddress " + DomainToClassMapping := nil. + self knownClassFromCode:#'AF_UNIX' self knownClassFromCode:#'AF_INET' @@ -484,5 +486,5 @@ !SocketAddress class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic2/SocketAddress.st,v 1.19 2003-07-09 15:31:29 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic2/SocketAddress.st,v 1.20 2003-07-14 11:10:36 cg Exp $' ! !