diff options
author | Ryo Nakamura <upa@haeena.net> | 2022-12-11 13:23:41 +0900 |
---|---|---|
committer | Ryo Nakamura <upa@haeena.net> | 2022-12-11 13:23:41 +0900 |
commit | d27db01d8d427b9a3ade4e82e73dba1bb3802781 (patch) | |
tree | a1d7c690413449d14ed411f2f7b63d729620e777 /src/file.c | |
parent | 45cde99a85269315b9f56b1523223e90973c7bd1 (diff) |
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.
Diffstat (limited to 'src/file.c')
-rw-r--r-- | src/file.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -554,7 +554,7 @@ int chunk_prepare(struct chunk *c, sftp_session sftp) struct file *f = c->f; int ret = 0; - lock_acquire(&f->lock); /* XXX: is always acquiring lock per-chunk heavy? */ + LOCK_ACQUIRE_THREAD(&f->lock); if (f->state == FILE_STATE_INIT) { if (file_dst_prepare(f, f->dst_is_remote ? sftp : NULL) < 0) { ret = -1; @@ -565,7 +565,7 @@ int chunk_prepare(struct chunk *c, sftp_session sftp) } out: - lock_release(&f->lock); + LOCK_RELEASE_THREAD(); return ret; } |