cURL / Mailing Lists / curl-library / Single Mail

curl-library

Reg: curl_multi_perform

From: Savitha Perumal <savithap_at_yahoo-inc.com>
Date: Fri, 17 Apr 2009 16:13:05 -0700

This is the piece of CURL code.

  struct CURLM *ysiCurlMultiHandle = 0;

  if(!ysiCurlMultiHandle) {
    if(!(ysiCurlMultiHandle = curl_multi_init())) {
      fprintf(stderr, "Could not init CURL Multi-handle\n");
      return(1);
    }
  }

  curl_easy_setopt(curl, CURLOPT_URL, url);
  .....
......
  curl_easy_setopt(curl, CURLOPT_POST, 1);
  curl_easy_setopt(curl, CURLOPT_POSTFIELDS, params);

  curl_multi_add_handle(ysiCurlMultiHandle, curl);

  // Make sure we don't take more than 100ms, but get as much
  // done as possible within that limit
  do {

    mcode = curl_multi_perform(ysiCurlMultiHandle, &handles);

    gettimeofday(&now, 0);
    usecdiff = 1000000 * (now.tv_sec - begin.tv_sec) +
      now.tv_usec - begin.tv_usec;

  } while ( (mcode==CURLM_CALL_MULTI_PERFORM || handles>0) &&
                (usecdiff < (maxusec < 0? 100000 : maxusec)) );

  // Remove & clean up completed handles
  while((message = curl_multi_info_read(ysiCurlMultiHandle, &handles))) {
    curl_easy_getinfo(message->easy_handle, CURLINFO_RESPONSE_CODE, &response);

    if(message->msg == CURLMSG_DONE) {
      // After calling curl_multi_remove_handle, message is invalidated,
      // though the easy handle it references is not.
      CURL* easy = message->easy_handle;
      curl_multi_remove_handle(ysiCurlMultiHandle, easy);
      curl_easy_cleanup(easy);
    }
  }

Problems I see :

* curl_multi_perform always returns handles=1
  I am using curl-7.19.4.
  I read somewhere that there is a patch that fixes this.
  Could you please advice which patch/version ?

* curl_multi_info_read most of the times returns NULL,
  even if it returns a message, the CURLINFO_RESPONSE_CODE is "0"

* Things are getting messed up if the size of the POST field is more than 1024k .
  Request 1 : abc123456......
  Request 2 : def123456......

During the time of processing, I see that curl is posting a request as
"abc1234def123456...."

This is just an example. Request 1 gets truncated at random position and Request 2
gets appended or so / something weird happens.

* Requests getting posted multiple times.
  Request 1 : abc123456....

I see that curl has sent this request again and again..
once with full information , 2nd time with partial information.

Please advice if you have experienced same / similar problems with curl.

Thanks
Savitha
Received on 2009-04-18