sanlock/SOURCES/0002-sanlock-fix-pthread_create-error-check.patch
2022-03-25 12:39:14 +00:00

52 lines
1.6 KiB
Diff

From e44c47c48a3a71502deacbafda851cb6d93e78c8 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Wed, 9 Mar 2022 15:25:11 -0600
Subject: [PATCH 2/4] sanlock: fix pthread_create error check
for non-zero rather than less than zero
---
src/lockspace.c | 4 ++--
src/main.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/lockspace.c b/src/lockspace.c
index d23dccd84815..582a0e973566 100644
--- a/src/lockspace.c
+++ b/src/lockspace.c
@@ -1070,8 +1070,8 @@ int add_lockspace_start(struct sanlk_lockspace *ls, uint32_t io_timeout, struct
(unsigned long long)sp->host_id_disk.offset);
rv = pthread_create(&sp->thread, NULL, lockspace_thread, sp);
- if (rv < 0) {
- log_erros(sp, "add_lockspace create thread failed");
+ if (rv) {
+ log_erros(sp, "add_lockspace create thread failed %d", rv);
goto fail_del;
}
diff --git a/src/main.c b/src/main.c
index 5b6fabc6d0b8..613fb0ee23d5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -995,7 +995,7 @@ static int thread_pool_add_work(struct cmd_args *ca)
if (!pool.free_workers && pool.num_workers < pool.max_workers) {
rv = pthread_create(&th, NULL, thread_pool_worker,
(void *)(long)pool.num_workers);
- if (rv < 0) {
+ if (rv) {
log_error("thread_pool_add_work ci %d error %d", ca->ci_in, rv);
list_del(&ca->list);
pthread_mutex_unlock(&pool.mutex);
@@ -1035,7 +1035,7 @@ static int thread_pool_create(int min_workers, int max_workers)
for (i = 0; i < min_workers; i++) {
rv = pthread_create(&th, NULL, thread_pool_worker,
(void *)(long)i);
- if (rv < 0)
+ if (rv)
break;
pool.num_workers++;
}
--
2.7.5