mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-27 02:53:10 +01:00
workaround for vista service automatic WSAStartup() crash issue
This commit is contained in:
@@ -89,4 +89,22 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
namespace Poco {
|
||||||
|
namespace Net {
|
||||||
|
|
||||||
|
|
||||||
|
void initializeNetwork();
|
||||||
|
/// Initialize the network subsystem.
|
||||||
|
/// Calls WSAStartup() on Windows, does nothing
|
||||||
|
/// on other platforms.
|
||||||
|
|
||||||
|
void uninitializeNetwork();
|
||||||
|
/// Uninitialize the network subsystem.
|
||||||
|
/// Calls WSACleanup() on Windows, does nothing
|
||||||
|
/// on other platforms.
|
||||||
|
|
||||||
|
|
||||||
|
} } // namespace Poco::Net
|
||||||
|
|
||||||
|
|
||||||
#endif // Net_Net_INCLUDED
|
#endif // Net_Net_INCLUDED
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ using Poco::IOException;
|
|||||||
//
|
//
|
||||||
// Automatic initialization of Windows networking
|
// Automatic initialization of Windows networking
|
||||||
//
|
//
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32) && !defined(POCO_NET_NO_AUTOMATIC_WSASTARTUP)
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
class NetworkInitializer
|
class NetworkInitializer
|
||||||
@@ -58,14 +58,12 @@ namespace
|
|||||||
public:
|
public:
|
||||||
NetworkInitializer()
|
NetworkInitializer()
|
||||||
{
|
{
|
||||||
WORD version = MAKEWORD(2, 2);
|
Poco::Net::initializeNetwork();
|
||||||
WSADATA data;
|
|
||||||
WSAStartup(version, &data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~NetworkInitializer()
|
~NetworkInitializer()
|
||||||
{
|
{
|
||||||
WSACleanup();
|
Poco::Net::uninitializeNetwork();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -236,4 +234,22 @@ void DNS::error(int code, const std::string& arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void initializeNetwork()
|
||||||
|
{
|
||||||
|
#if defined(_WIN32)
|
||||||
|
WORD version = MAKEWORD(2, 2);
|
||||||
|
WSADATA data;
|
||||||
|
WSAStartup(version, &data);
|
||||||
|
#endif // _WIN32
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void uninitializeNetwork()
|
||||||
|
{
|
||||||
|
#if defined(_WIN32)
|
||||||
|
WSACleanup();
|
||||||
|
#endif // _WIN32
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::Net
|
} } // namespace Poco::Net
|
||||||
|
|||||||
Reference in New Issue
Block a user