Made the Visual Studio compiler a bit more happy with aicurl.

This commit is contained in:
Shyotl
2012-07-17 18:04:48 -05:00
parent 0204d09a89
commit 48ae0d003d
5 changed files with 42 additions and 24 deletions

View File

@@ -123,6 +123,13 @@ void ssl_locking_function(int mode, int n, char const* file, int line)
}
}
#if LL_WINDOWS
static unsigned long __cdecl apr_os_thread_current_wrapper()
{
return (unsigned long)apr_os_thread_current();
}
#endif
#if HAVE_CRYPTO_THREADID
// OpenSSL uniq id function.
void ssl_id_function(CRYPTO_THREADID* thread_id)
@@ -216,8 +223,12 @@ void ssl_init(void)
// Setting this avoids the need for a thread-local error number facility, which is hard to check.
#if HAVE_CRYPTO_THREADID
CRYPTO_THREADID_set_callback(&ssl_id_function);
#else
#if LL_WINDOWS
CRYPTO_set_id_callback(&apr_os_thread_current_wrapper);
#else
CRYPTO_set_id_callback(&apr_os_thread_current);
#endif
#endif
// Dynamic locks callbacks.
old_ssl_dyn_create_function = CRYPTO_get_dynlock_create_callback();
@@ -286,7 +297,7 @@ void initCurl(void (*flush_hook)())
llwarns << "libcurl's age is 0; no ares support." << llendl;
}
llassert_always((version_info->features & CURL_VERSION_SSL)); // SSL support, added in libcurl 7.10.
if (!(version_info->features & CURL_VERSION_ASYNCHDNS)); // Asynchronous name lookups (added in libcurl 7.10.7).
if (!(version_info->features & CURL_VERSION_ASYNCHDNS)) // Asynchronous name lookups (added in libcurl 7.10.7).
{
llwarns << "libcurl was not compiled with support for asynchronous name lookups!" << llendl;
}
@@ -1313,8 +1324,8 @@ CurlMultiHandle::~CurlMultiHandle()
{
curl_multi_cleanup(mMultiHandle);
Stats::multi_calls++;
int total = --sTotalMultiHandles;
Dout(dc::curl, "Called CurlMultiHandle::~CurlMultiHandle() [" << (void*)this << "], " << total << " remaining.");
--sTotalMultiHandles;
Dout(dc::curl, "Called CurlMultiHandle::~CurlMultiHandle() [" << (void*)this << "], " << sTotalMultiHandles << " remaining.");
}
} // namespace AICurlPrivate

View File

@@ -233,6 +233,7 @@ typedef AIAccess<AICurlPrivate::CurlEasyRequest> AICurlEasyRequest_wat;
// Events generated by AICurlPrivate::CurlEasyHandle.
struct AICurlEasyHandleEvents {
virtual ~AICurlEasyHandleEvents(){}
// Events.
virtual void added_to_multi_handle(AICurlEasyRequest_wat& curl_easy_request_w) = 0;
virtual void finished(AICurlEasyRequest_wat& curl_easy_request_w) = 0;

View File

@@ -32,9 +32,11 @@
#include "aicurlthread.h"
#include "lltimer.h" // ms_sleep
#include <sys/types.h>
#if !LL_WINDOWS
#include <sys/select.h>
#include <unistd.h>
#include <fcntl.h>
#endif
#include <deque>
#undef AICurlPrivate
@@ -132,7 +134,7 @@ namespace curlthread {
//
// mMaxFdSet is the largest filedescriptor in mFdSet or -1 if it is empty.
static size_t const MAXSIZE = std::max(1024, FD_SETSIZE);
static size_t const MAXSIZE = llmax(1024, FD_SETSIZE);
// Create an empty PollSet.
PollSet::PollSet(void) : mFileDescriptors(new curl_socket_t [MAXSIZE]),
@@ -147,10 +149,10 @@ PollSet::PollSet(void) : mFileDescriptors(new curl_socket_t [MAXSIZE]),
// Add filedescriptor s to the PollSet.
void PollSet::add(curl_socket_t s)
{
llassert_always(mNrFds < MAXSIZE);
llassert_always(mNrFds < (int)MAXSIZE);
mFileDescriptors[mNrFds++] = s;
#if !LL_WINDOWS
mMaxFd = std::max(mMaxFd, s);
mMaxFd = llmax(mMaxFd, s);
#endif
}
@@ -195,7 +197,7 @@ void PollSet::remove(curl_socket_t s)
curl_socket_t next = mFileDescriptors[--i]; // next = 'd'
mFileDescriptors[i] = cur; // Overwrite 'd' with 'e'.
#if !LL_WINDOWS
max = std::max(max, cur); // max is the maximum value in 'i' or higher.
max = llmax(max, cur); // max is the maximum value in 'i' or higher.
#endif
cur = next; // cur = 'd'
// i NrFds = 5
@@ -214,7 +216,7 @@ void PollSet::remove(curl_socket_t s)
// i NrFds = 5
// v v
// index: 0 1 2 3 4
// a b c d e // max = std::max('d', 'e')
// a b c d e // max = llmax('d', 'e')
// If mNext pointed to an element before s, it should be left alone. Otherwise, if mNext pointed
// to s it must now point to 'd', or if it pointed beyond 's' it must be decremented by 1.
@@ -228,7 +230,7 @@ void PollSet::remove(curl_socket_t s)
while (i > 0)
{
curl_socket_t next = mFileDescriptors[--i];
max = std::max(max, next);
max = llmax(max, next);
}
mMaxFd = max;
llassert(mMaxFd < s);
@@ -256,7 +258,7 @@ void PollSet::remove(curl_socket_t s)
mFileDescriptors[i] = cur;
cur = next;
}
if (mIter > i)
if (mIter > (unsigned int)i)
--mIter;
llassert(mIter <= mFdSet.fd_count);
}
@@ -278,7 +280,7 @@ inline bool PollSet::is_set(curl_socket_t fd) const
inline void PollSet::clr(curl_socket_t fd)
{
return FD_CLR(fd, &mFdSet);
FD_CLR(fd, &mFdSet);
}
// This function fills mFdSet with at most FD_SETSIZE - 1 filedescriptors,
@@ -312,7 +314,7 @@ refresh_t PollSet::refresh(void)
// Calculate mMaxFdSet.
// Run over FD_SETSIZE - 1 elements, starting at mNext, wrapping to 0 when we reach the end.
int max = -1, i = mNext, count = 0;
while (++count < FD_SETSIZE) { max = std::max(max, mFileDescriptors[i]); if (++i == mNrFds) i = 0; }
while (++count < FD_SETSIZE) { max = llmax(max, mFileDescriptors[i]); if (++i == mNrFds) i = 0; }
mMaxFdSet = max;
#endif
}
@@ -587,9 +589,9 @@ AICurlThread::~AICurlThread()
// MAIN-THREAD
void AICurlThread::create_wakeup_fds(void)
{
#ifdef WINDOWS
// Probably need to use sockets here, cause Windows select doesn't work for a pipe.
#error Missing implementation
#if LL_WINDOWS
// Probably need to use sockets here, cause Windows select doesn't work for a pipe.
#error Missing implementation
#else
int pipefd[2];
if (pipe(pipefd))
@@ -612,10 +614,14 @@ void AICurlThread::create_wakeup_fds(void)
// MAIN-THREAD
void AICurlThread::cleanup_wakeup_fds(void)
{
#if LL_WINDOWS
#error Missing implementation
#else
if (mWakeUpFd_in != CURL_SOCKET_BAD)
close(mWakeUpFd_in);
if (mWakeUpFd != CURL_SOCKET_BAD)
close(mWakeUpFd);
#endif
}
// MAIN-THREAD
@@ -632,8 +638,8 @@ void AICurlThread::wakeup_thread(void)
return;
}
#ifdef WINDOWS
#error Missing implementation
#ifdef LL_WINDOWS
#error Missing implementation
#else
// If write() is interrupted by a signal before it writes any data, it shall return -1 with errno set to [EINTR].
// If write() is interrupted by a signal after it successfully writes some data, it shall return the number of bytes written.
@@ -662,8 +668,8 @@ void AICurlThread::wakeup(AICurlMultiHandle_wat const& multi_handle_w)
{
DoutEntering(dc::curl, "AICurlThread::wakeup");
#ifdef WINDOWS
#error Missing implementation
#ifdef LL_WINDOWS
#error Missing implementation
#else
// If a read() is interrupted by a signal before it reads any data, it shall return -1 with errno set to [EINTR].
// If a read() is interrupted by a signal after it has successfully read some data, it shall return the number of bytes read.
@@ -758,9 +764,9 @@ void AICurlThread::run(void)
fd_set* write_fd_set = ((wres & empty)) ? NULL : multi_handle_w->mWritePollSet.access();
// Calculate nfds (ignored on windows).
#if !LL_WINDOWS
curl_socket_t const max_rfd = std::max(multi_handle_w->mReadPollSet.get_max_fd(), mWakeUpFd);
curl_socket_t const max_rfd = llmax(multi_handle_w->mReadPollSet.get_max_fd(), mWakeUpFd);
curl_socket_t const max_wfd = multi_handle_w->mWritePollSet.get_max_fd();
int nfds = std::max(max_rfd, max_wfd) + 1;
int nfds = llmax(max_rfd, max_wfd) + 1;
llassert(0 <= nfds && nfds <= FD_SETSIZE);
llassert((max_rfd == -1) == (read_fd_set == NULL) &&
(max_wfd == -1) == (write_fd_set == NULL)); // Needed on Windows.

View File

@@ -105,7 +105,7 @@ class PollSet
std::vector<curl_socket_t> mCopiedFileDescriptors; // Filedescriptors copied by refresh to mFdSet.
std::vector<curl_socket_t>::iterator mIter; // Index into mCopiedFileDescriptors for next(); loop variable.
#else
int mIter; // Index into fd_set::fd_array.
unsigned int mIter; // Index into fd_set::fd_array.
#endif
};

View File

@@ -16,7 +16,7 @@
<view_border bevel_style="none" border_thickness="1" bottom_delta="0" follows="top|left" height="75"
left="235" name="CmdDivisor" width="0"/>
-->
<text bottom="-15" left="250" name="objects_link_text_box2" width="300">Chat:</text>
<text bottom="-15" left="250" name="objects_link_text_box2" width="300">Chat:</text>
<check_box bottom_delta="-25" left_delta="-5" follows="left|top" control_name="PlayTypingSound" initial_value="true"
label="Play the typing sound for local chat" tool_tip="Silences the chatting type sound, making it quieter for things like performances." name="play_typing_sound_check"/>
<check_box bottom_delta="-20" follows="left|top" control_name="HideNotificationsInChat" initial_value="false"
@@ -25,7 +25,7 @@
label="Allow MU pose method." tool_tip="Allows the use of both /me and : to perform emotes." name="allow_mu_pose_check"/>
<check_box bottom_delta="-20" follows="left|top" control_name="AscentAutoCloseOOC"
label="Auto-close OOC comments." tool_tip="Will automatically append '))' to any message starting with '((', or visa versa." name="close_ooc_check"/>
<text bottom_delta="-15" follows="left|top" name="objects_link_text_box3">Show links on chatting object names in chat history for:</text>
<text bottom_delta="-15" follows="left|top" name="objects_link_text_box3">Show links on chatting object names in chat history for:</text>
<radio_group bottom_delta="-26" control_name="LinksForChattingObjects" tool_tip="Enables a link to show you the owner of the speaking object."
follows="top" height="20" left="20" name="objects_link" width="350">
<radio_item bottom_delta="0" left_delta="5" name="no_object" width="48">No object</radio_item>