cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: extract max keepalive requests configuration using a discovery loop

From: Roberto Nibali <ratz_at_drugphish.ch>
Date: Tue, 27 Sep 2005 23:59:23 +0200

> Why is there no libcurl_easy_getopt()? Just curious.
>
> The loop looks as follows now:
>
> void perftest_rundisc(CURL *curl) {
> CURLcode res;
> unsigned int loop;
> unsigned int new_conn;
> unsigned int skip;
> long con;
>
> fprintf(stderr, "Explicitly disabling following 302\n");
> res = curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 0);
> res = curl_easy_setopt(curl, CURLOPT_URL, "http://some.site.com/");
> new_conn = 0;
> loop = 0;
> skip = 1;
> while (new_conn == 0 && loop < MAX_LOOP) {
> res = curl_easy_perform(curl);
> res = curl_easy_getinfo(curl, CURLINFO_NUM_CONNECTS, &con);
> check_retval(res, 0, __FILE__, __LINE__);

Forgot to remove the above line, it's my error handling function.

> if (con > 0) {
> if (skip == 1) {
> skip = 0;
> } else {
> new_conn = 1;
> }
> }
> if (new_conn == 0) {
> loop_sleep();
> }
> loop++;
> }
> fprintf(stderr, "Amount of cons through same socket: %d\n",loop);

That's: s/loop/loop-1/ actually, since the last request was done using a
new socket, we don't count this. Well, so it's only a off-by-1 error now
;). I can live with that.

Cheers,
Roberto Nibali, ratz

-- 
echo 
'[q]sa[ln0=aln256%Pln256/snlbx]sb3135071790101768542287578439snlbxq' | dc
Received on 2005-09-28