cURL
Haxx ad
libcurl

Shopping cart software, Online file storage, Online photo storage, Hosted shopping cart, Contact management software, Email marketing software, Project management software, Issue tracking software, Online notepad, Web publishing software

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-library Archives

Values of Running handles

From: <centrio_at_gmail.com>
Date: Fri, 27 Nov 2009 05:17:14 +0000

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

These mail archives are generated by hypermail.

donate! Page updated November 16, 2009.
web site info

File upload with ASP.NET