cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: bitmap buffer (c++)

From: <iamsal_at_interfree.it>
Date: 15 Nov 2008 09:29:57 -0000

>Changing a single-threaded application that crashes into a multi-threaded
>application is probably not going to make the
>problem any easier to find, but I guess it never hurts to try.

When the application run as single-threaded it doesn't crash, but when there are more applications running (not in a multithread application but as separate applications) occurs this problem with memcpy.
(i posted the code)

>If you have a libcurl-using application that crashes, that is "really similar"
>to a libcurl-using example that doesn't
>crash, the problem is likely not in libcurl.
I agree...
I know libcurl is thread-safe, but perhaps i use it in the wrong way!

>Have you tried running your program inside a debugger to see where the crash
>occurs, and what state the data is in
>when it happens?
Yes , i posted it, the crash occurs when i try to copy the chunk buffer in the iplimage, it seems
like if all the threads are using the same adress for a pointer (i don' understand if the problem is the iplimage pointer or the chunk one)

>
>From the little bit you've shown so far, what I would guess is that the server
>sometimes sends back a response header
>(probably something other than 200/OK) but doesn't send any
>data after that. In that case, your write callback never
>gets called, and your chunk.memory remains NULL. If that
>happens, then your call to memcpy will certainly crash.
>Just because curl_easy_perform returns CURLE_OK, it doesn't indicate that
>everything worked perfectly. It just means
>libcurl connected to the server, and got some sort of a
>response, but the response could be any number of things
>besides a successful download. So you may also want to
>test for something like:
>
> long resp;
> curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &resp);
> if (resp != 200) {
> /* something went wrong! */
> }
>
>But still, you should check that (chunk.memory!=NULL)
>before trying to read its contents.

thanks, i made these controls, all work fine with the trasmission.

>
>And again, sometimes CURLOPT_VERBOSE can really help!
After you said it to me i've used.
The results are that two identical connections are opened, the first thread does its work, copying the buffer and closing the connection, after that the second thread is unable to access the chunk.

Thank you for your precious help
best regards
manu

>
>- Jeff
>

----------------------------------------------------------------------------
Vuoi essere presente online?
Vuoi dare voce alla tua attivita`?
Acquista un dominio su domini.interfree.it.
A partire da 18,59 euro
----------------------------------------------------------------------------
Received on 2008-11-15