Can you reproduce the issue with current git version?
yes I can
Could you provide a code snippet that would expose the issue, or even
better a new test case that exposes it?
I attached demo code which reproduces the issue with the easy interface,
I tested it with multi as well with the same result.
The code makes 2 curl requests with one easy-handle which one is reused
the second time. with wireshark I see the connection is indeed reused.
the result (console output) is:
....
curl finished--------------------
res:0 -> "No error" -> ""
lip:127.0.0.1 lport:53701 <---> rip:127.0.0.1 rport:80
easy end--------------------
easy start----------------
...
curl finished--------------------
res:0 -> "No error" -> ""
lip: lport:0 <---> rip:127.0.0.1 rport:0
easy end--------------------
Making Curl_updateconninfo() unconditionally execute its code for
reused connections introduces a needless performance penalty. If
there's actually a problem, we better fix the origin of the problem.
completely agreed. I have to have a look at the code. I had the
impression the (ip/port)information has to be copied to the handle in
both cases new and reused, but may be I'm wrong.
#include <stdio.h>
#include <curl/curl.h>
CURL *curl=NULL;
void printTCPInfo(CURL *curl)
{
char* rip = NULL;
char* lip = NULL;
long rport = -1;
long lport = -1;
curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, &rip);
curl_easy_getinfo(curl, CURLINFO_LOCAL_IP, &lip);
curl_easy_getinfo(curl, CURLINFO_PRIMARY_PORT, &rport);
curl_easy_getinfo(curl, CURLINFO_LOCAL_PORT, &lport);
printf("lip:%s lport:%ld <---> rip:%s rport:%ld\n",lip?lip:"na", lport, rip?rip:"na", rport);
}
void performEasyRequest(const char* cUrl)
{
CURLcode res;
if (!curl)
{
curl = curl_easy_init();
printf("curl handle init\n");
}
else
{
curl_easy_reset(curl);
}
if (curl)
{
printf("easy start----------------\n");
printf("URL:%s\n",cUrl);
char errorBuffer[CURL_ERROR_SIZE];
errorBuffer[0] = '\0';
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER , errorBuffer);
curl_easy_setopt(curl, CURLOPT_URL, cUrl);
res = curl_easy_perform(curl);
printf("curl finished--------------------\n");
printf("res:%d -> \"%s\" -> \"%s\" \n",res, curl_easy_strerror(res), errorBuffer);
printTCPInfo(curl);
printf("easy end--------------------\n");
}
}
int main(int argc, char* argv[])
{
const char* cUrl= "127.0.0.1";
if ( argc>1 )
{
cUrl=argv[1];
}
performEasyRequest(cUrl);
performEasyRequest(cUrl);
return 0;
}
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html