[dm-devel] [PATCH 13/16] multipath: find_multipaths_check_timeout(): no need for pthread cleanup

mwilck at suse.com mwilck at suse.com
Thu Sep 1 16:09:49 UTC 2022


From: Martin Wilck <mwilck at suse.com>

multipath is not a multithreaded program, no pthread-cancel complexity
is necesssary here.

Signed-off-by: Martin Wilck <mwilck at suse.com>
---
 multipath/main.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/multipath/main.c b/multipath/main.c
index fbff6b7..7b69a3c 100644
--- a/multipath/main.c
+++ b/multipath/main.c
@@ -321,7 +321,7 @@ static int find_multipaths_check_timeout(const struct path *pp, long tmo,
 	char path[PATH_MAX];
 	struct timespec now, ftimes[2], tdiff;
 	struct stat st;
-	int fd = -1;
+	int fd;
 	int r, retries = 0;
 
 	clock_gettime(CLOCK_REALTIME, &now);
@@ -339,9 +339,8 @@ static int find_multipaths_check_timeout(const struct path *pp, long tmo,
 retry:
 	fd = open(path, O_RDONLY);
 	if (fd != -1) {
-		pthread_cleanup_push(cleanup_fd_ptr, &fd);
 		r = fstat(fd, &st);
-		pthread_cleanup_pop(1);
+		close(fd);
 
 	} else if (tmo > 0) {
 		if (errno == ENOENT)
@@ -355,7 +354,6 @@ retry:
 			return FIND_MULTIPATHS_ERROR;
 		};
 
-		pthread_cleanup_push(cleanup_fd_ptr, &fd);
 		/*
 		 * We just created the file. Set st_mtim to our desired
 		 * expiry time.
@@ -369,7 +367,7 @@ retry:
 				path, strerror(errno));
 		}
 		r = fstat(fd, &st);
-		pthread_cleanup_pop(1);
+		close(fd);
 	} else
 		return FIND_MULTIPATHS_NEVER;
 
-- 
2.37.1



More information about the dm-devel mailing list