diff --git a/indra/cmake/Cwdebug.cmake b/indra/cmake/Cwdebug.cmake index f68c7a897..d469386e1 100644 --- a/indra/cmake/Cwdebug.cmake +++ b/indra/cmake/Cwdebug.cmake @@ -2,7 +2,6 @@ include_directories (${CMAKE_SOURCE_DIR}/cwdebug) set(cwdebug_SOURCE_FILES ${CMAKE_SOURCE_DIR}/cwdebug/debug.cc - ${CMAKE_SOURCE_DIR}/cwdebug/debug_libcurl.cc ) set(cwdebug_HEADER_FILES @@ -10,7 +9,6 @@ set(cwdebug_HEADER_FILES ${CMAKE_SOURCE_DIR}/cwdebug/sys.h ${CMAKE_SOURCE_DIR}/cwdebug/debug.h ${CMAKE_SOURCE_DIR}/cwdebug/debug_ostream_operators.h - ${CMAKE_SOURCE_DIR}/cwdebug/debug_libcurl.h ) set_source_files_properties(${cwdebug_HEADER_FILES} diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt index b2b8eb4ec..aac669137 100644 --- a/indra/llmessage/CMakeLists.txt +++ b/indra/llmessage/CMakeLists.txt @@ -30,6 +30,7 @@ set(llmessage_SOURCE_FILES llcircuit.cpp llclassifiedflags.cpp aicurl.cpp + debug_libcurl.cpp aicurlthread.cpp lldatapacker.cpp lldispatcher.cpp @@ -117,6 +118,7 @@ set(llmessage_HEADER_FILES llclassifiedflags.h llcurl.h aicurl.h + debug_libcurl.h aicurlprivate.h aicurlthread.h lldatapacker.h diff --git a/indra/llmessage/aicurl.h b/indra/llmessage/aicurl.h index 4752d1b45..895650ec8 100644 --- a/indra/llmessage/aicurl.h +++ b/indra/llmessage/aicurl.h @@ -37,11 +37,16 @@ #include #include #include + +#include "llpreprocessor.h" #include // Needed for files that include this header (also for aicurlprivate.h). +#ifdef DEBUG_CURLIO #include "debug_libcurl.h" +#endif // Make sure we don't use this option: it is not thread-safe. #undef CURLOPT_DNS_USE_GLOBAL_CACHE +#define CURLOPT_DNS_USE_GLOBAL_CACHE do_not_use_CURLOPT_DNS_USE_GLOBAL_CACHE #include "stdtypes.h" // U32 #include "lliopipe.h" // LLIOPipe::buffer_ptr_t diff --git a/indra/llmessage/aicurlthread.cpp b/indra/llmessage/aicurlthread.cpp index c03a0f309..4d56a0622 100644 --- a/indra/llmessage/aicurlthread.cpp +++ b/indra/llmessage/aicurlthread.cpp @@ -177,6 +177,19 @@ int closesocket(curl_socket_t fd) return close(fd); } +int const FIONBIO = 0; + +int ioctlsocket(int fd, int, unsigned long* nonblocking_enable) +{ + int res = fcntl(fd, F_GETFL, 0); + llassert_always(res != -1); + if (*nonblocking_enable) + res |= O_NONBLOCK; + else + res &= ~O_NONBLOCK; + return fcntl(fd, F_SETFD, res); +} + #endif // DEBUG_WINDOWS_CODE_ON_LINUX #define WINDOWS_CODE (LL_WINDOWS || DEBUG_WINDOWS_CODE_ON_LINUX) @@ -894,7 +907,7 @@ static int dumb_socketpair(SOCKET socks[2], bool make_overlapped) WSASetLastError(e); return SOCKET_ERROR; } -#else +#elif WINDOWS_CODE int dumb_socketpair(int socks[2], int dummy) { (void) dummy; @@ -913,18 +926,18 @@ void AICurlThread::create_wakeup_fds(void) llerrs << "Failed to generate wake-up socket pair" << formatWSAError() << llendl; return; } - u_long nonblocking_enable = TRUE; - int error = ioctlsocket(socks[0], FIONBIO, &nonblocking_enable); - if(error) - { - llerrs << "Failed to set wake-up socket nonblocking: " << formatWSAError() << llendl; - } - llassert(nonblocking_enable); - error = ioctlsocket(socks[1], FIONBIO, &nonblocking_enable); - if(error) - { - llerrs << "Failed to set wake-up input socket nonblocking: " << formatWSAError() << llendl; - } + u_long nonblocking_enable = TRUE; + int error = ioctlsocket(socks[0], FIONBIO, &nonblocking_enable); + if(error) + { + llerrs << "Failed to set wake-up socket nonblocking: " << formatWSAError() << llendl; + } + llassert(nonblocking_enable); + error = ioctlsocket(socks[1], FIONBIO, &nonblocking_enable); + if(error) + { + llerrs << "Failed to set wake-up input socket nonblocking: " << formatWSAError() << llendl; + } mWakeUpFd = socks[0]; mWakeUpFd_in = socks[1]; #else @@ -933,7 +946,7 @@ void AICurlThread::create_wakeup_fds(void) { llerrs << "Failed to create wakeup pipe: " << strerror(errno) << llendl; } - long flags = O_NONBLOCK; + int const flags = O_NONBLOCK; for (int i = 0; i < 2; ++i) { if (fcntl(pipefd[i], F_SETFL, flags)) diff --git a/indra/cwdebug/debug_libcurl.cc b/indra/llmessage/debug_libcurl.cpp similarity index 99% rename from indra/cwdebug/debug_libcurl.cc rename to indra/llmessage/debug_libcurl.cpp index 05df113c8..b2bdd6f64 100644 --- a/indra/cwdebug/debug_libcurl.cc +++ b/indra/llmessage/debug_libcurl.cpp @@ -4,6 +4,8 @@ #include #include #include +#include "llpreprocessor.h" +#include #define COMPILING_DEBUG_LIBCURL_CC #include "debug_libcurl.h" #include "../llcommon/llerror.h" @@ -801,6 +803,7 @@ char* debug_curl_version(void) } -#else +#else // DEBUG_CURLIO int debug_libcurl_dummy; // I thought some OS didn't like empty source files. -#endif +#endif // DEBUG_CURLIO + diff --git a/indra/cwdebug/debug_libcurl.h b/indra/llmessage/debug_libcurl.h similarity index 91% rename from indra/cwdebug/debug_libcurl.h rename to indra/llmessage/debug_libcurl.h index bcf15e0f0..98884f077 100644 --- a/indra/cwdebug/debug_libcurl.h +++ b/indra/llmessage/debug_libcurl.h @@ -1,9 +1,19 @@ #ifndef DEBUG_LIBCURL #define DEBUG_LIBCURL -#ifdef DEBUG_CURLIO +#ifndef DEBUG_CURLIO +#error "Don't include debug_libcurl.h unless DEBUG_CURLIO is defined." +#endif + +#ifndef CURLINFO_TYPEMASK +#error " must be included before including debug_libcurl.h!" +#endif + +#ifndef LLPREPROCESSOR_H +// CURL_STATICLIB is needed on windows namely, which is defined in llpreprocessor.h (but only on windows). +#error "llpreprocessor.h must be included before ." +#endif -#include #include "debug.h" extern "C" { @@ -78,6 +88,4 @@ extern CWD_API char* debug_curl_version(void); #endif // !COMPILING_DEBUG_LIBCURL_CC -#endif // DEBUG_CURLIO - #endif // DEBUG_LIBCURL diff --git a/indra/newview/hipporestrequest.cpp b/indra/newview/hipporestrequest.cpp index 4cd0cc34c..60d7770a1 100644 --- a/indra/newview/hipporestrequest.cpp +++ b/indra/newview/hipporestrequest.cpp @@ -8,14 +8,16 @@ #endif #include -#include -#include -#include -#include -#include +#include "llbufferstream.h" +#include "llerror.h" +#include "llhttpclient.h" +#include "llurlrequest.h" +#include "llxmltree.h" #include +#ifdef DEBUG_CURLIO #include "debug_libcurl.h" +#endif // ******************************************************************** diff --git a/indra/newview/llurlsimstring.cpp b/indra/newview/llurlsimstring.cpp index a28988db5..200345cae 100644 --- a/indra/newview/llurlsimstring.cpp +++ b/indra/newview/llurlsimstring.cpp @@ -38,7 +38,10 @@ #include "llpanellogin.h" #include "llviewercontrol.h" -#include "curl/curl.h" +#include // curl_unescape, curl_free +#ifdef DEBUG_CURLIO +#include "debug_libcurl.h" +#endif //static LLURLSimString LLURLSimString::sInstance; diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp index ab95ee14d..307edffdd 100644 --- a/indra/newview/llwaterparammanager.cpp +++ b/indra/newview/llwaterparammanager.cpp @@ -76,8 +76,6 @@ #include "llagentcamera.h" -#include "curl/curl.h" - LLWaterParamManager::LLWaterParamManager() : mFogColor(22.f/255.f, 43.f/255.f, 54.f/255.f, 0.0f, 0.0f, "waterFogColor", "WaterFogColor"), mFogDensity(4, "waterFogDensity", 2),