mirror of
https://github.com/upa/mscp.git
synced 2026-02-14 17:24:42 +08:00
use pthread_cleanup to acquire and release lock
In chunk_prepare(), if multiple threads wait for acquiring f->lock, and then pthread_cancel() is called, the waiting threads are never canceled because pthread_mutex_lock() is not a cancellation point. So, use pthread_cleanup_push/pop to release the lock.
This commit is contained in:
@@ -507,9 +507,9 @@ void *mscp_copy_thread(void *arg)
|
||||
pthread_cleanup_push(mscp_copy_thread_cleanup, t);
|
||||
|
||||
while (1) {
|
||||
lock_acquire(&m.chunk_lock);
|
||||
LOCK_ACQUIRE_THREAD(&m.chunk_lock);
|
||||
c = chunk_acquire(&m.chunk_list);
|
||||
lock_release(&m.chunk_lock);
|
||||
LOCK_RELEASE_THREAD();
|
||||
|
||||
if (!c)
|
||||
break; /* no more chunks */
|
||||
|
||||
Reference in New Issue
Block a user