diff options
author | Mattias Andrée <maandree@kth.se> | 2022-02-15 11:26:03 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2022-02-15 11:26:03 +0100 |
commit | 3bbc3c84094333f9097e04461ceef71d4152ad42 (patch) | |
tree | 58bfa717a4e55e81a9e09260dabd87976fee212e | |
parent | m (diff) | |
download | libar2simplified-3bbc3c84094333f9097e04461ceef71d4152ad42.tar.gz libar2simplified-3bbc3c84094333f9097e04461ceef71d4152ad42.tar.bz2 libar2simplified-3bbc3c84094333f9097e04461ceef71d4152ad42.tar.xz |
Rewait if sem_wait is interrupted (pthread_mutex_lock cannot be interrupted)
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r-- | libar2simplified_hash.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/libar2simplified_hash.c b/libar2simplified_hash.c index b21ef5b..e5765f5 100644 --- a/libar2simplified_hash.c +++ b/libar2simplified_hash.c @@ -85,6 +85,8 @@ thread_loop(void *data_) for (;;) { if (sem_wait(&data->semaphore)) { + if (errno == EINTR) + continue; data->error = errno; return NULL; } @@ -299,8 +301,11 @@ await_threads(size_t *indices, size_t n, size_t require, struct libar2_context * for (;;) { if (ret < require) { - if (sem_wait(&data->semaphore)) + if (sem_wait(&data->semaphore)) { + if (errno == EINTR) + continue; return 0; + } } else if (sem_trywait(&data->semaphore)) { if (errno == EAGAIN) break; |