From 86a63fc554afe1a8bf9c16384a16a5822207990d Mon Sep 17 00:00:00 2001 From: RandumKiwi Date: Sun, 10 Nov 2013 18:54:27 +0000 Subject: [PATCH] Fix for some buggy libcurl versions (linux). git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@7656 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/client.cpp | 6 ++++-- source/src/serverbrowser.cpp | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/source/src/client.cpp b/source/src/client.cpp index 225c1c62..e16c522e 100644 --- a/source/src/client.cpp +++ b/source/src/client.cpp @@ -940,6 +940,7 @@ int pingpckservers(void *data) pckserver *serv = &serverstoping[i]; CURL *cu = curl_easy_init(); curl_easy_setopt(cu, CURLOPT_URL, serv->addr); + curl_easy_setopt(cu, CURLOPT_NOSIGNAL, 1); // Fixes crashbug for some buggy libcurl versions (Linux) curl_easy_setopt(cu, CURLOPT_NOPROGRESS, 1); curl_easy_setopt(cu, CURLOPT_NOBODY, 1); // don't download response body (as its size may vary a lot from one server to another) curl_easy_setopt(cu, CURLOPT_CONNECTTIMEOUT, 10); // the timeout should be large here @@ -954,7 +955,7 @@ int pingpckservers(void *data) else serv->ping = (int)(ping*1000); } - + SDL_mutexP(pingpcksrvlock); loopv(serverstoping) loopvj(pckservers) if(!strcmp(serverstoping[i].addr, pckservers[j]->addr)) *pckservers[j] = serverstoping[i]; pckservers.sort(pckserversort); @@ -1060,6 +1061,7 @@ double dlpackage(package *pck) double dlsize; pck->curl = curl_easy_init(); curl_easy_setopt(pck->curl, CURLOPT_URL, req); + curl_easy_setopt(pck->curl, CURLOPT_NOSIGNAL, 1); // Fixes crashbug for some buggy libcurl versions (Linux) curl_easy_setopt(pck->curl, CURLOPT_WRITEFUNCTION, write_callback); curl_easy_setopt(pck->curl, CURLOPT_WRITEDATA, outfile); curl_easy_setopt(pck->curl, CURLOPT_NOPROGRESS, 0); @@ -1159,4 +1161,4 @@ void writepcksourcecfg() loopv(pckservers) f->printf("\naddpckserver %s", pckservers[i]->addr); f->printf("\n"); delete f; -} \ No newline at end of file +} diff --git a/source/src/serverbrowser.cpp b/source/src/serverbrowser.cpp index 4a7295d3..3185cb60 100644 --- a/source/src/serverbrowser.cpp +++ b/source/src/serverbrowser.cpp @@ -1312,7 +1312,7 @@ void retrieveservers(vector &data) resolver_data *rd = new resolver_data(); formatstring(rd->text)("retrieving servers from %s:%d... (esc to abort)", mastername, masterport); show_out_of_renderloop_progress(0, rd->text); - + rd->starttime = SDL_GetTicks(); rd->timeout = 0; @@ -1320,6 +1320,7 @@ void retrieveservers(vector &data) int result = 0, httpresult = 0; curl_easy_setopt(curl, CURLOPT_URL, request); + curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); // Fixes crashbug for some buggy libcurl versions (Linux) curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); @@ -1331,7 +1332,7 @@ void retrieveservers(vector &data) curl_easy_cleanup(curl); curl = NULL; if(outfile) fclose(outfile); - + if(result == CURLE_OPERATION_TIMEDOUT || result == CURLE_COULDNT_RESOLVE_HOST) { clfail = true;