fixed SF# 1985180: Poco::Net::DNS multithreading issue

This commit is contained in:
Guenter Obiltschnig
2008-06-09 14:21:56 +00:00
parent b3d124f14a
commit 076c301460
4 changed files with 131 additions and 40 deletions

View File

@@ -1,7 +1,7 @@
//
// HostEntry.cpp
//
// $Id: //poco/svn/Net/src/HostEntry.cpp#2 $
// $Id: //poco/Main/Net/src/HostEntry.cpp#8 $
//
// Library: Net
// Package: NetCore
@@ -43,12 +43,17 @@ namespace Poco {
namespace Net {
HostEntry::HostEntry()
//
// HostEntryImpl
//
HostEntryImpl::HostEntryImpl()
{
}
HostEntry::HostEntry(struct hostent* entry)
HostEntryImpl::HostEntryImpl(struct hostent* entry)
{
poco_check_ptr (entry);
@@ -77,7 +82,7 @@ HostEntry::HostEntry(struct hostent* entry)
#if defined(_WIN32) && defined(POCO_HAVE_IPv6)
HostEntry::HostEntry(struct addrinfo* ainfo)
HostEntryImpl::HostEntryImpl(struct addrinfo* ainfo)
{
poco_check_ptr (ainfo);
@@ -94,32 +99,34 @@ HostEntry::HostEntry(struct addrinfo* ainfo)
#endif
HostEntry::HostEntry(const HostEntry& entry):
_name(entry._name),
_aliases(entry._aliases),
_addresses(entry._addresses)
HostEntryImpl::~HostEntryImpl()
{
}
HostEntry& HostEntry::operator = (const HostEntry& entry)
//
// HostEntry
//
HostEntry::HostEntry():
_pImpl(new HostEntryImpl)
{
}
HostEntry::HostEntry(struct hostent* entry):
_pImpl(new HostEntryImpl(entry))
{
if (&entry != this)
{
_name = entry._name;
_aliases = entry._aliases;
_addresses = entry._addresses;
}
return *this;
}
void HostEntry::swap(HostEntry& hostEntry)
#if defined(_WIN32) && defined(POCO_HAVE_IPv6)
HostEntry::HostEntry(struct addrinfo* info):
_pImpl(new HostEntryImpl(info))
{
std::swap(_name, hostEntry._name);
std::swap(_aliases, hostEntry._aliases);
std::swap(_addresses, hostEntry._addresses);
}
#endif
HostEntry::~HostEntry()
@@ -127,4 +134,18 @@ HostEntry::~HostEntry()
}
HostEntry::HostEntry(const HostEntry& entry):
_pImpl(entry._pImpl)
{
}
HostEntry& HostEntry::operator = (const HostEntry& entry)
{
HostEntry tmp(entry);
tmp.swap(*this);
return *this;
}
} } // namespace Poco::Net