cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Multithreaded Issues

From: Rob Mason <rmason_at_archivas.com>
Date: Tue, 24 Aug 2004 17:45:58 -0400

Thanks, it may seem odd, but I don't actually care that i'm constantly
writing over my data on each call. I still haven't run into an
explanation for contention between PUTs and GETs when running
multithreaded.
Rob

>> Rob,
>>
>> As far as your write callback (used by GET), it looks like it is
>> keeping
>> track of how much total data has been received, but each call the
>> memcpy
>> call is just copying the received chunk of data to the beginning of
>> the
>> buffer, rather than copying it after data that has already been
>> received.
>> So maybe you need to change this line:
>>
>> memcpy(stream, ptr, my_size);
>>
>> To something like this:
>>
>> memcpy(((char*) stream) + sizeLeft[thread_id], ptr, my_size);
>>
>> After you do this, you still need to guard against more than
>> BIG_BUFFER_SIZE
>> bytes received over multiple calls.
>>
>> Also, in your read callback, it looks like the first two arguments to
>> memcpy
>> are reversed.
>>
>> I hope this is helpful!
>>
>>
>> Dylan
Received on 2004-08-24