501230
--- xen-4.6.3/tools/xenstore/xs.c.orig	2016-06-20 13:08:22.000000000 +0100
501230
+++ xen-4.6.3/tools/xenstore/xs.c	2016-07-10 21:05:57.082217329 +0100
501230
@@ -733,6 +733,7 @@
501230
 	if (!h->read_thr_exists) {
501230
 		sigset_t set, old_set;
501230
 		pthread_attr_t attr;
501230
+		int ptret;
501230
 
501230
 		if (pthread_attr_init(&attr) != 0) {
501230
 			mutex_unlock(&h->request_mutex);
501230
@@ -747,7 +748,12 @@
501230
 		sigfillset(&set);
501230
 		pthread_sigmask(SIG_SETMASK, &set, &old_set);
501230
 
501230
-		if (pthread_create(&h->read_thr, &attr, read_thread, h) != 0) {
501230
+		ptret = pthread_create(&h->read_thr, &attr, read_thread, h);
501230
+		if ( (ptret == EINVAL) && (pthread_attr_setstacksize(&attr, READ_THREAD_STACKSIZE + (8*1024)) == 0) ) {
501230
+			/* have a second try with the bigger stacksize */
501230
+			ptret = pthread_create(&h->read_thr, &attr, read_thread, h);
501230
+		}
501230
+		if (ptret != 0) {
501230
 			pthread_sigmask(SIG_SETMASK, &old_set, NULL);
501230
 			pthread_attr_destroy(&attr);
501230
 			mutex_unlock(&h->request_mutex);