cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Is the callback specified in CURLOPT_WRITEFUNCTION thread-safe?

From: Ajay Garg <ajaygargnsit_at_gmail.com>
Date: Fri, 4 Jul 2014 17:05:00 +0530

On Thu, Jul 3, 2014 at 1:04 AM, Dan Fandrich <dan_at_coneharvesters.com> wrote:

> On Thu, Jul 03, 2014 at 12:12:34AM +0530, Ajay Garg wrote:
> > On Wed, Jul 2, 2014 at 1:11 AM, Dan Fandrich <dan_at_coneharvesters.com>
> wrote:
> > If that's followed there will never be an
> > opportunity to mix up received data since the handle passed in to the
> > callback
> > in each thread will be different.
> >
> >
> > You mean the "ptr" handle is different for each thread, in the callback
> of
> > type:
> >
> > size_t write_callback(char *ptr, size_t size, size_t
> nmemb,
> > void *userdata);
>
> ptr will point to a different internal libcurl buffer for each curl
> handle, and
> since these handles are never shared between threads, yes, it will be
> different
> in each thread. The userdata pointer will be whatever was set on the
> handle by
> the application, so it can be different in each thread as well, if desired.
>

Neat !!!

Thanks for the concise, to-the-point reply !!

>
> >>> Dan
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html
>

Thanks and Regards,
Ajay

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-07-04