Hi,
I have a code that looks like this :
void LoopOverMultiPerform(ConnectionState state) const
{
fd_set read_fds;
fd_set write_fds;
fd_set ex_fds;
int32 runningHandles = 0;
struct timeval timeOut;
timeOut.tv_sec = 0;
timeOut.tv_usec = 0;
if (CONNECTIONSTATE_CONNECT == state)
{
timeOut.tv_sec = SELECT_CONNECT_TIMEOUT;
}
else if (CONNECTIONSTATE_DATA == state)
{
timeOut.tv_usec = DATA_TIMEOUT;
}
if (curlMultiStatusCode == CURLM_OK)
{
FD_ZERO(&read_fds);
FD_ZERO(&write_fds);
FD_ZERO(&ex_fds);
int32 max_fd;
curlMultiStatusCode = curl_multi_fdset(curlMultiHandle,
&read_fds, &write_fds, &ex_fds, &max_fd);
if (CURLM_OK != sessionData->curlMultiStatusCode)
{
throw NException("Fatal error");
}
if (-1 < max_fd)
{
int32 ret = select(max_fd+1, &read_fds, &write_fds, &ex_fds, &timeOut);
switch(ret)
{
case 0 : break;
case -1: //Some error has occured on the socket.
endOfMedia = true;
internalBufferUsed = 0;
throw NException("select() Failed");
break;
}
}
}
curlMultiStatusCode = curl_multi_perform(curlMultiHandle,
&runningHandles);
// If no handles are running, it implies that connection with the server
has been lost.
// If the transfer is complete/ or connection is closed then runnnig
handles become 0
if (0 == runningHandles)
{
endOfMedia = true;
internalBufferUsed = 0;
}
}
This function is called in a loop, And I break the loop if endOfMedia ==
true.
Some thing like this :
while ( (internalBufferSize == 0) && !endOfMedia)
{
ReceiveStreamContent(CONNECTIONSTATE_CONNECT);
{
boost::mutex::scoped_lock interruptThreadLock(guardInterrupt);
if (isInterrupted)
{
endOfMedia = true;
internalBufferUsed = 0;
isInterrupted = false;
throw ConnectException("Interrupted");
}
}
}
I wanted to know if this is a valid condition to break the loop. Is it true
that runningHandles will become 0 only if the Connection is closed. What is
its 0 since the beginning and never become 1.? Is it possible that
runningHandles never take the value 1 according to above code?
Please help.
Best Regards
Shivanand
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2009-11-27