Hi

This patch solves slow responses from remote nodes. Author is Al Stone
(in CC); he's not on the list as far as I know.

I've tested the patch and it does do the trick. Without the patch
response was ~3 seconds, while now it's ~0.3 seconds.
Index: pacemaker-1.1.2+hg20100918/cib/remote.c
===================================================================
--- pacemaker-1.1.2+hg20100918.orig/cib/remote.c	2010-09-24 16:35:20.194327792 -0600
+++ pacemaker-1.1.2+hg20100918/cib/remote.c	2010-09-24 16:43:40.725007445 -0600
@@ -57,6 +57,10 @@
 #  endif
 #endif
 
+#ifdef HAVE_DECL_NANOSLEEP
+#  include <time.h>
+#endif
+
 extern int remote_tls_fd;
 int init_remote_listener(int port, gboolean encrypted);
 
@@ -209,6 +213,10 @@
 	cl_uuid_t client_id;
 	char uuid_str[UU_UNPARSE_SIZEOF];
 	
+#ifdef HAVE_DECL_NANOSLEEP
+	const struct timespec sleepfast = { 0, 1000000 }; /* 1 millisec */
+#endif
+
 	/* accept the connection */
 	laddr = sizeof(addr);
 	csock = accept(ssock, (struct sockaddr*)&addr, &laddr);
@@ -242,7 +250,14 @@
 		} else {
 		    login = cib_recv_remote_msg(GINT_TO_POINTER(csock), FALSE);
 		}
+		if (login != NULL) {
+		    break;
+		}
+#ifdef HAVE_DECL_NANOSLEEP
+		nanosleep(&sleepfast, NULL);
+#else
 		sleep(1);
+#endif
 		
 	} while(login == NULL && ++lpc < 10);
 	
Index: pacemaker-1.1.2+hg20100918/configure.ac
===================================================================
--- pacemaker-1.1.2+hg20100918.orig/configure.ac	2010-09-24 16:33:41.996424087 -0600
+++ pacemaker-1.1.2+hg20100918/configure.ac	2010-09-24 16:34:22.684911759 -0600
@@ -775,6 +775,7 @@
 
 AC_CHECK_FUNCS(g_log_set_default_handler)
 AC_CHECK_FUNCS(getopt, AC_DEFINE(HAVE_DECL_GETOPT,  1, [Have getopt function]))
+AC_CHECK_FUNCS(nanosleep, AC_DEFINE(HAVE_DECL_NANOSLEEP,  1, [Have nanosleep function]))
 
 dnl ========================================================================
 dnl   ltdl
_______________________________________________
Pacemaker mailing list: Pacemaker@oss.clusterlabs.org
http://oss.clusterlabs.org/mailman/listinfo/pacemaker

Project Home: http://www.clusterlabs.org
Getting started: http://www.clusterlabs.org/doc/Cluster_from_Scratch.pdf
Bugs: http://developerbugs.linux-foundation.org/enter_bug.cgi?product=Pacemaker

Reply via email to