cURL / Mailing Lists / curl-library / Single Mail

curl-library

Question about synchronization and the progress callback

From: Saqib Ali <saqib.ali.75_at_gmail.com>
Date: Fri, 18 Mar 2011 11:48:12 -0400

Sorry for the amateurish questions, but, Is it reasonable to assume that the
progress callback function will only be invoked after the previous call to
the progress function has completed returned?

I would like to serialize calls to the progress callback in this way. The
action I'm taking in the function takes a significant amount of time. So I'm
seeing overlapping calls to the progress function. To deal with this, I've
inserted a mutex as such:

include <pthread.h>

int progressCallBack(void *clientp, double dltotal, double dlnow, double
ultotal, double ulnow)
{

pthread_mutex_lock( &callbackMutex );

// Do my time-consuming action here

pthread_mutex_unlock( &callbackMutex );

}

What I'm seeing is that the mutex lock seems to get ignored. My
assumption/understanding of the cURL multi-stack was that each easy-handle
has its own thread which calls the progress function. Threads within the
same process should respect mutex locks. Is there a gap in my understanding?

- Saqib

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-03-18