@@ -50,11 +50,13 @@ #import "OFThread+Private.h" #import "OFAutoreleasePool+Private.h" #import "OFAutoreleasePool.h" #import "OFDate.h" #import "OFDictionary.h" -#import "OFList.h" +#ifdef OF_HAVE_SOCKETS +# import "OFDNSResolver.h" +#endif #import "OFLocale.h" #import "OFRunLoop.h" #import "OFString.h" #ifdef OF_WINDOWS @@ -128,10 +130,12 @@ objc_autoreleasePoolPop(thread->_pool); [OFAutoreleasePool of_handleThreadTermination]; [thread release]; } +#else +static OFDNSResolver *DNSResolver; #endif @implementation OFThread #ifdef OF_HAVE_THREADS @synthesize name = _name; @@ -182,10 +186,32 @@ thread->_threadDictionary = [[OFMutableDictionary alloc] init]; return thread->_threadDictionary; } #endif + +#ifdef OF_HAVE_SOCKETS ++ (OFDNSResolver *)DNSResolver +{ +# ifdef OF_HAVE_THREADS + OFThread *thread = of_tlskey_get(threadSelfKey); + + if (thread == nil) + return nil; + + if (thread->_DNSResolver == nil) + thread->_DNSResolver = [[OFDNSResolver alloc] init]; + + return thread->_DNSResolver; +# else + if (DNSResolver == nil) + DNSResolver = [[OFDNSResolver alloc] init]; + + return DNSResolver; +# endif +} +#endif + (void)sleepForTimeInterval: (of_time_interval_t)timeInterval { if (timeInterval < 0) return; @@ -352,10 +378,15 @@ _runLoop = nil; [oldRunLoop release]; [_threadDictionary release]; _threadDictionary = nil; + +# ifdef OF_HAVE_SOCKETS + [_DNSResolver release]; + _DNSResolver = nil; +# endif } - (void)start { if (_running == OF_THREAD_RUNNING)