- win32 winsock bugfixes causing havok and grief for win32 users (corrupt winsock stack due to extra call to wsacleanup)
This commit is contained in:
parent
d8e28fbf90
commit
9ba8668751
|
@ -695,7 +695,9 @@ void MenuStateMasterserver::simpleTask(BaseThread *callingThread) {
|
|||
if(announcementURL != "") {
|
||||
|
||||
safeMutex.ReleaseLock(true);
|
||||
std::string announcementTxt = SystemFlags::getHTTP(announcementURL);
|
||||
CURL *handle = SystemFlags::initHTTP();
|
||||
std::string announcementTxt = SystemFlags::getHTTP(announcementURL,handle);
|
||||
SystemFlags::cleanupHTTP(&handle);
|
||||
if(callingThread->getQuitStatus() == true) {
|
||||
return;
|
||||
}
|
||||
|
@ -728,7 +730,9 @@ void MenuStateMasterserver::simpleTask(BaseThread *callingThread) {
|
|||
//printf("\nversionURL=%s\n",versionURL.c_str());
|
||||
if(versionURL != "") {
|
||||
safeMutex.ReleaseLock(true);
|
||||
std::string versionTxt = SystemFlags::getHTTP(versionURL);
|
||||
CURL *handle = SystemFlags::initHTTP();
|
||||
std::string versionTxt = SystemFlags::getHTTP(versionURL,handle);
|
||||
SystemFlags::cleanupHTTP(&handle);
|
||||
if(callingThread->getQuitStatus() == true) {
|
||||
return;
|
||||
}
|
||||
|
@ -769,7 +773,9 @@ void MenuStateMasterserver::simpleTask(BaseThread *callingThread) {
|
|||
if(Config::getInstance().getString("Masterserver","") != "") {
|
||||
|
||||
safeMutex.ReleaseLock(true);
|
||||
std::string localServerInfoString = SystemFlags::getHTTP(Config::getInstance().getString("Masterserver") + "showServersForGlest.php");
|
||||
CURL *handle = SystemFlags::initHTTP();
|
||||
std::string localServerInfoString = SystemFlags::getHTTP(Config::getInstance().getString("Masterserver") + "showServersForGlest.php",handle);
|
||||
SystemFlags::cleanupHTTP(&handle);
|
||||
if(callingThread->getQuitStatus() == true) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ class Socket : public SimpleTaskCallbackInterface {
|
|||
|
||||
protected:
|
||||
#ifdef WIN32
|
||||
SocketManager wsaManager;
|
||||
static SocketManager wsaManager;
|
||||
#endif
|
||||
PLATFORM_SOCKET sock;
|
||||
time_t lastDebugEvent;
|
||||
|
|
|
@ -396,7 +396,7 @@ socket_t ftpCreateServerSocket(int portNumber)
|
|||
|
||||
if(bind(theServer, (struct sockaddr *)&serverinfo, len))
|
||||
{
|
||||
if(VERBOSE_MODE_ENABLED) printf("\ERROR In ftpCreateServerSocket bind FAILED about to close listener socket = %d\n",theServer);
|
||||
if(VERBOSE_MODE_ENABLED) printf("\nERROR In ftpCreateServerSocket bind FAILED about to close listener socket = %d\n",theServer);
|
||||
|
||||
ftpUntrackSocket(theServer);
|
||||
ftpCloseSocket(&theServer);
|
||||
|
@ -405,7 +405,7 @@ socket_t ftpCreateServerSocket(int portNumber)
|
|||
|
||||
if(listen(theServer, 100))
|
||||
{
|
||||
if(VERBOSE_MODE_ENABLED) printf("\ERROR In ftpCreateServerSocket listen FAILED about to close listener socket = %d\n",theServer);
|
||||
if(VERBOSE_MODE_ENABLED) printf("\nERROR In ftpCreateServerSocket listen FAILED about to close listener socket = %d\n",theServer);
|
||||
|
||||
ftpUntrackSocket(theServer);
|
||||
ftpCloseSocket(&theServer);
|
||||
|
|
|
@ -39,6 +39,7 @@ ip_t ownIp;
|
|||
LOCAL fd_set watchedSockets;
|
||||
LOCAL fd_set signaledSockets;
|
||||
LOCAL int maxSockNr;
|
||||
int wsaInitCount=0;
|
||||
|
||||
void ftpArchInit()
|
||||
{
|
||||
|
@ -46,12 +47,19 @@ void ftpArchInit()
|
|||
ownIp = 0;
|
||||
maxSockNr = 0;
|
||||
FD_ZERO(&watchedSockets);
|
||||
if(VERBOSE_MODE_ENABLED) printf("Feathery calling WSAStartup...\n");
|
||||
WSAStartup(MAKEWORD(2, 0),&wsaData);
|
||||
wsaInitCount++;
|
||||
}
|
||||
|
||||
void ftpArchCleanup(void)
|
||||
{
|
||||
WSACleanup(); // WINSOCK freigeben
|
||||
if(VERBOSE_MODE_ENABLED) printf("Feathery calling WSACleanup...[%d]\n",wsaInitCount);
|
||||
if(wsaInitCount > 0)
|
||||
{
|
||||
WSACleanup(); // WINSOCK freigeben
|
||||
wsaInitCount--;
|
||||
}
|
||||
}
|
||||
|
||||
int ftpGetLocalTime(ftpTime_S *t)
|
||||
|
@ -319,7 +327,7 @@ socket_t ftpEstablishDataConnection(int passive, ip_t *ip, port_t *port, int ses
|
|||
myAddr.sin_port = htons(passivePort);
|
||||
//myAddr.sin_port = htons(ftpGetPassivePort() + sessionId);
|
||||
|
||||
if(setsockopt(dataSocket, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)))
|
||||
if(setsockopt(dataSocket, SOL_SOCKET, SO_REUSEADDR, (const char *)&on, sizeof(on)))
|
||||
{
|
||||
if(VERBOSE_MODE_ENABLED) printf("PASSIVE CONNECTION In ftpEstablishDataConnection setsockopt failed about to Close socket = %d, for sessionId = %d\n",dataSocket, sessionId);
|
||||
|
||||
|
@ -428,7 +436,7 @@ socket_t ftpCreateServerSocket(int portNumber)
|
|||
|
||||
if(bind(theServer, (struct sockaddr *)&serverinfo, len))
|
||||
{
|
||||
if(VERBOSE_MODE_ENABLED) printf("\ERROR In ftpCreateServerSocket bind FAILED about to close listener socket = %d\n",theServer);
|
||||
if(VERBOSE_MODE_ENABLED) printf("\nERROR In ftpCreateServerSocket bind FAILED about to close listener socket = %d\n",theServer);
|
||||
|
||||
ftpUntrackSocket(theServer);
|
||||
ftpCloseSocket(&theServer);
|
||||
|
@ -437,7 +445,7 @@ socket_t ftpCreateServerSocket(int portNumber)
|
|||
|
||||
if(listen(theServer, 100))
|
||||
{
|
||||
if(VERBOSE_MODE_ENABLED) printf("\ERROR In ftpCreateServerSocket listen FAILED about to close listener socket = %d\n",theServer);
|
||||
if(VERBOSE_MODE_ENABLED) printf("\nERROR In ftpCreateServerSocket listen FAILED about to close listener socket = %d\n",theServer);
|
||||
|
||||
ftpUntrackSocket(theServer);
|
||||
ftpCloseSocket(&theServer);
|
||||
|
|
|
@ -214,17 +214,20 @@ bool UPNP_Tools::enabledUPNP = false;
|
|||
return acErrorBuffer;
|
||||
}
|
||||
|
||||
//SocketManager Socket::socketManager;
|
||||
// keeps in scope for duration of the application
|
||||
SocketManager Socket::wsaManager;
|
||||
|
||||
SocketManager::SocketManager() {
|
||||
WSADATA wsaData;
|
||||
WORD wVersionRequested = MAKEWORD(2, 0);
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("SocketManager calling WSAStartup...\n");
|
||||
WSAStartup(wVersionRequested, &wsaData);
|
||||
//dont throw exceptions here, this is a static initializacion
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"Winsock initialized.\n");
|
||||
}
|
||||
|
||||
SocketManager::~SocketManager() {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("SocketManager calling WSACleanup...\n");
|
||||
WSACleanup();
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"Winsock cleanup complete.\n");
|
||||
}
|
||||
|
|
|
@ -171,6 +171,9 @@ CURL *SystemFlags::initHTTP() {
|
|||
//printf("In [%s::%s Line %d] curl_global_init called and returned: result %d [%s]\n",__FILE__,__FUNCTION__,__LINE__,result,curl_easy_strerror(result));
|
||||
}
|
||||
CURL *handle = curl_easy_init();
|
||||
if(handle == NULL) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d] ERROR handle = NULL\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
curl_easy_setopt(handle, CURLOPT_NOSIGNAL, 1);
|
||||
return handle;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue