[PATCH] makedumpfile: Fix a bug when multi-threads feature meets enospace

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Currently, when multi-threads feature meets enospace error,
the main thread will call pthread_join(). However, there is one
thread doing while{} and won't stop.

                pthread_mutex_lock(&info->page_data_mutex);
                while (page_data_buf[index].used != FALSE) {
                        index = (index + 1) % info->num_buffers;
                }
                page_data_buf[index].used = TRUE;
                pthread_mutex_unlock(&info->page_data_mutex);

Then makedumpfile hangs.

This patch add a cancel point in while{}.

Signed-off-by: Zhou Wenjian <zhouwj.fi@xxxxxxxxx>
---
 makedumpfile.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/makedumpfile.c b/makedumpfile.c
index ed138d3..f7ad50c 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -7731,11 +7731,13 @@ kdump_thread_function_cyclic(void *arg) {
 		buf_ready = FALSE;
 
 		pthread_mutex_lock(&info->page_data_mutex);
+		pthread_cleanup_push(pthread_mutex_unlock, &info->page_data_mutex);
 		while (page_data_buf[index].used != FALSE) {
+			pthread_testcancel();
 			index = (index + 1) % info->num_buffers;
 		}
 		page_data_buf[index].used = TRUE;
-		pthread_mutex_unlock(&info->page_data_mutex);
+		pthread_cleanup_pop(1); 
 
 		while (buf_ready == FALSE) {
 			pthread_testcancel();
-- 
1.8.3.1


_______________________________________________
kexec mailing list
kexec@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/kexec



[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux