File multipath-tools-multipathd-dies-after-startup of Package multipath-tools

From 15887203753bd54cb40f5962aa977d02d6f82775 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Thu, 19 Feb 2009 16:18:44 +0100
Subject: [PATCH] multipathd dies immediately after start

Multipathd is unable to run on SLES 11 -rc3 on IA64 system.
System is connected to MSA 1500 HP array. Only one lun is presented
to system.
Problem is that multipathd tries to set the pthread stack to
32kB, which is too small for ia64. So the call to pthread_create()
fails. Solution is to check the stacksize first and only increase
it if required.

References: 473029

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 libmultipath/waiter.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/libmultipath/waiter.c b/libmultipath/waiter.c
index 530180f..9e89811 100644
--- a/libmultipath/waiter.c
+++ b/libmultipath/waiter.c
@@ -197,6 +197,7 @@ int start_waiter_thread (struct multipath *mpp, struct vectors *vecs)
 {
 	pthread_attr_t attr;
 	struct event_thread *wp;
+	size_t stacksize;
 
 	if (!mpp)
 		return 0;
@@ -204,7 +205,19 @@ int start_waiter_thread (struct multipath *mpp, struct vectors *vecs)
 	if (pthread_attr_init(&attr))
 		goto out;
 
-	pthread_attr_setstacksize(&attr, 32 * 1024);
+	if (pthread_attr_getstacksize(&attr, &stacksize) != 0)
+		stacksize = PTHREAD_STACK_MIN;
+
+	/* Check if the stacksize is large enough */
+	if (stacksize < (32 * 1024))
+		stacksize = 32 * 1024;
+
+	/* Set stacksize and try to reinitialize attr if failed */
+	if (stacksize > PTHREAD_STACK_MIN &&
+	    pthread_attr_setstacksize(&attr, stacksize) != 0 &&
+	    pthread_attr_init(&attr))
+		goto out;
+
 	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
 
 	wp = alloc_waiter();
-- 
1.6.0.2

openSUSE Build Service is sponsored by