cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: Disconnection occurs without any error returned

From: Fadi Kahhaleh <fkahhaleh_at_hotmail.com>
Date: Wed, 6 Jun 2012 03:53:11 +0000

From: amrnablus_at_gmail.com
Date: Wed, 6 Jun 2012 01:39:36 +0300
Subject: Re: Disconnection occurs without any error returned
To: curl-library_at_cool.haxx.se

A code sample would help

On Wed, Jun 6, 2012 at 12:21 AM, Fadi Kahhaleh <fkahhaleh_at_hotmail.com> wrote:

Hi all,
 
I am running into a very strange problem that is causing me to go into circles!
Using LibCurl has been a great experience over all as it is very flexible and easy to use.
 
Now I am running into some issues and it is driving me crazy, one of them which could be libCURL

related or not (hoping that you guys would be able to shed some light on) is the following:
 
I am downloading a video stream from one of our servers and I am getting a close connection debug info with curl Return Code of 0 (ZERO)

for no reason after running for several hours. (this could be 3 hours, 9 hours, and have seen it go to 16 and 24 hours!)
 
What is the best way to go about debugging this issue?
if I use VLC, it runs perfectly without problems for 24+ hours and all is good, so it is not the source.

 
I have defined the callback function and I did notice that there is an 8-byte memory leak in there, can't be sure if it is internal or my code, but
i doubt it has something to do with this issue, and will try to iron it out later once I settle this.

Thanks
 
Fadi

                                               

-------------------------------------------------------------------

List admin: http://cool.haxx.se/list/listinfo/curl-library

Etiquette: http://curl.haxx.se/mail/etiquette.html
I have based off the inmemory sample code, here is the two methods, not sure how much of help it will be! size_t AVStreamer::DownloadCallback(void *contents, size_t size, size_t nmemb, void *userp)
{
  size_t realsize = size * nmemb;
 AVStreamer *vs = (AVStreamer*)userp;
 int byteCnt = 0;
 static int timerCount = 0;
 do
 {
  if(WaitForSingleObject(vs->mre_DecoderExit,0) == WAIT_OBJECT_0)
  {
   //we have to exit! AVStreamer::PrintError(L"Exiting CallBack function for CURL due to mre_DecoderExit\r\n");
   return 0;
  } WaitForSingleObject(vs->hMux,INFINITE);
  
  byteCnt = vs->ringBuf.GetWriteAvail();
  ReleaseMutex(vs->hMux);
  Sleep(10);
   }
 while(byteCnt < realsize);
 WaitForSingleObject(vs->hMux,INFINITE);
 byteCnt = vs->ringBuf.Write((byte*)contents,realsize);
 ReleaseSemaphore(vs->hSemaphore,1, NULL);
 ReleaseMutex(vs->hMux);
 return realsize;
} WORD AVStreamer::StreamURL(void *arg)
{
 AVStreamer *locals = (AVStreamer*)arg;
 CURL *curl_handle;
 CURLcode ret;
 curl_global_init(CURL_GLOBAL_WIN32);
 //curl_global_init(CURL_GLOBAL_ALL);
  
 /* init the curl session */
 curl_handle = curl_easy_init();
 
 curl_easy_setopt(curl_handle, CURLOPT_DEBUGFUNCTION,curl_debug_callback);
 curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, TRUE);
 
 /* specify URL to get */
 curl_easy_setopt(curl_handle, CURLOPT_URL, locals->filename);
 
  /* send all data to this function */
  curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, DownloadCallback);
  /* we pass our 'chunk' struct to the callback function */
  curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)locals);
   
 /* some servers don't like requests that are made without a user-agent
     field, so we provide one */
 curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "libcurl-agent/1.0");
 
 /* get it! */
 ret = curl_easy_perform(curl_handle);
 AVStreamer::PrintError(L"Exited from CURL completely with return value: %i\r\n",ret); /* cleanup curl stuff */
 curl_easy_cleanup(curl_handle); /* we're done with libcurl, so clean it up */
 curl_global_cleanup();
 return 0;
}

                                               

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2012-06-06