Merge branch 'curlthreading2' of git://github.com/AlericInglewood/SingularityViewer into curlthreading
This commit is contained in:
@@ -1118,7 +1118,7 @@ CurlResponderBuffer::CurlResponderBuffer()
|
||||
curl_easy_request_w->send_events_to(this);
|
||||
}
|
||||
|
||||
#define llmaybeerrs lllog(LLApp::isRunning ? LLError::LEVEL_ERROR : LLError::LEVEL_WARN, NULL, NULL, false)
|
||||
#define llmaybeerrs lllog(LLApp::isRunning() ? LLError::LEVEL_ERROR : LLError::LEVEL_WARN, NULL, NULL, false)
|
||||
|
||||
// The callbacks need to be revoked when the CurlResponderBuffer is destructed (because that is what the callbacks use).
|
||||
// The AIThreadSafeSimple<CurlResponderBuffer> is destructed first (right to left), so when we get here then the
|
||||
@@ -1138,7 +1138,7 @@ CurlResponderBuffer::~CurlResponderBuffer()
|
||||
// in which case AICurlEasyRequestStateMachine::mTimer times out, but that already
|
||||
// calls CurlResponderBuffer::timed_out().
|
||||
llmaybeerrs << "Calling ~CurlResponderBuffer() with active responder!" << llendl;
|
||||
if (LLApp::isExiting())
|
||||
if (!LLApp::isRunning())
|
||||
{
|
||||
// It might happen if some CurlResponderBuffer escaped clean up somehow :/
|
||||
mResponder = NULL;
|
||||
|
||||
@@ -845,27 +845,50 @@ void AICurlThread::wakeup(AICurlMultiHandle_wat const& multi_handle_w)
|
||||
// If no process has the pipe open for writing, read() shall return 0 to indicate end-of-file.
|
||||
// If some process has the pipe open for writing and O_NONBLOCK is set, read() shall return -1 and set errno to [EAGAIN].
|
||||
char buf[256];
|
||||
ssize_t len;
|
||||
do
|
||||
bool got_data = false;
|
||||
for(;;)
|
||||
{
|
||||
len = read(mWakeUpFd, buf, sizeof(buf));
|
||||
if (len == -1 && errno == EAGAIN)
|
||||
ssize_t len = read(mWakeUpFd, buf, sizeof(buf));
|
||||
if (len > 0)
|
||||
{
|
||||
// Data was read from the pipe.
|
||||
got_data = true;
|
||||
if (len < sizeof(buf))
|
||||
break;
|
||||
}
|
||||
else if (len == -1)
|
||||
{
|
||||
// An error occurred.
|
||||
if (errno == EAGAIN)
|
||||
{
|
||||
if (got_data)
|
||||
break;
|
||||
// There was no data, even though select() said so. If this ever happens at all(?), lets just return and enter select() again.
|
||||
return;
|
||||
}
|
||||
else if (errno == EINTR)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
llerrs << "read(3) from mWakeUpFd: " << strerror(errno) << llendl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// pipe(2) returned 0.
|
||||
llwarns << "read(3) from mWakeUpFd returned 0, indicating that the pipe on the other end was closed! Shutting down curl thread." << llendl;
|
||||
close(mWakeUpFd);
|
||||
mWakeUpFd = CURL_SOCKET_BAD;
|
||||
mRunning = false;
|
||||
return;
|
||||
}
|
||||
while(len == -1 && errno == EINTR);
|
||||
if (len == -1)
|
||||
{
|
||||
llerrs << "read(3) from mWakeUpFd: " << strerror(errno) << llendl;
|
||||
}
|
||||
if (LL_UNLIKELY(len == 0))
|
||||
{
|
||||
llwarns << "read(3) from mWakeUpFd returned 0, indicating that the pipe on the other end was closed! Shutting down curl thread." << llendl;
|
||||
close(mWakeUpFd);
|
||||
mWakeUpFd = CURL_SOCKET_BAD;
|
||||
mRunning = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
// Data was received on mWakeUpFd. This means that the main-thread added one
|
||||
// or more commands to the command queue and called wakeUpCurlThread().
|
||||
process_commands(multi_handle_w);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user