Bugs item #2627315, was opened at 2009-02-22 11:19
Message generated for change (Comment added) made by bagder
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=2627315&group_id=976
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: libcurl
Group: wrong behaviour
>Status: Pending
Resolution: Invalid
Priority: 5
Private: No
Submitted By: mybugaccount mybugaccount (mybugaccount)
Assigned to: Daniel Stenberg (bagder)
Summary: multithreading problem - couldn't resolve host
Initial Comment:
I use libcurl 7.19.2 precompiled for mingw. When I use multiple threads function curl_easy_perform() returns CURLE_COULDNT_RESOLVE_HOST. When I use critical sections to serialize CURL calls it doesn't help also. With one thread only my code works well.
----------------------------------------------------------------------
Comment By: Daniel Stenberg (bagder)
Date: 2009-02-23 22:32
Message:
Thanks for reporting this issue and helping us improve curl and libcurl.
We're awaiting feedback in this issue. Due to this, I have set the state
of this issue to pending and it will automatically get closed later on
unless we get further info.
Please consider answering the outstanding questions or providing the
missing info so that we can proceed to resolve this issue!
----------------------------------------------------------------------
Comment By: Dan Fandrich (dfandrich)
Date: 2009-02-22 22:28
Message:
There's no call to curl_global_init() in the provided code, which means
that two of the three threads start running before the Winsock init
completes.
----------------------------------------------------------------------
Comment By: mybugaccount mybugaccount (mybugaccount)
Date: 2009-02-22 13:58
Message:
Ok, there is the source code compiled with mingw 3.4.2 and linked with
libcurldll.a (7.19.2).
Only the first thread runs fine, two others returns
CURLE_COULDNT_RESOLVE_HOST.
#include <windows.h>
#include <curl/curl.h>
static size_t wd_null(void *ptr, size_t size, size_t nmemb, void *stream)
{
return size*nmemb;
}
DWORD WINAPI threadFunc(LPVOID param)
{
int *p=(int*)param;
int id=*p;
char user[1024];
char pass[1024];
if (id==0)
{
strcpy(user,"user0");
strcpy(pass,"pass0");
}
if (id==1)
{
strcpy(user,"user1");
strcpy(pass,"pass1");
}
if (id==2)
{
strcpy(user,"user2");
strcpy(pass,"pass2");
}
CURL *curl;
curl = curl_easy_init();
if (curl)
{
curl_easy_setopt(curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;
MSIE 6.0; Windows NT 5.1)");
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "");
}
else
{
return 0;
}
CURLcode res;
char post_login[1024];
sprintf(post_login,"login=%s&password=%s",user,pass);
// here the original address was replaced with www.google.com,
// but the code still returns the same error
curl_easy_setopt(curl, CURLOPT_URL, "http://www.google.com/login");
curl_easy_setopt(curl, CURLOPT_POST, 1);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, post_login);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(post_login));
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, wd_null);
res = curl_easy_perform(curl);
if (res!=0)
{
char msg[1024];
sprintf(msg,"error %d in thread %d\n",res,id);
MessageBox(0,msg,"err",MB_OK);
}
return 1;
}
int main()
{
int id0,id1,id2;
id0=0;
id1=1;
id2=2;
DWORD threadid1,threadid2,threadid3;
HANDLE h1=CreateThread(0,1024*1024,threadFunc,&id0,0,&threadid1);
HANDLE h2=CreateThread(0,1024*1024,threadFunc,&id1,0,&threadid2);
HANDLE h3=CreateThread(0,1024*1024,threadFunc,&id2,0,&threadid3);
Sleep(10000);
return 0;
}
----------------------------------------------------------------------
Comment By: Daniel Stenberg (bagder)
Date: 2009-02-22 13:18
Message:
This kind of generic report is next to useless. We have a large amount of
users who use libcurl in threaded apps with no problems.
Please back up your claims with facts, most preferably with a small fully
working source code that reproduces it.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=2627315&group_id=976
Received on 2009-02-23