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

[Cluster-devel] cluster/cman/lib libcman.c libcman.h



CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	fabbione sourceware org	2007-11-05 16:43:50

Modified files:
	cman/lib       : libcman.c libcman.h 

Log message:
	Add cman_wait_init as wrapper for cman_admin_init/cman_init and cman_is_quorate

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/lib/libcman.c.diff?cvsroot=cluster&r1=1.37&r2=1.38
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cman/lib/libcman.h.diff?cvsroot=cluster&r1=1.35&r2=1.36

--- cluster/cman/lib/libcman.c	2007/09/18 15:34:41	1.37
+++ cluster/cman/lib/libcman.c	2007/11/05 16:43:50	1.38
@@ -354,6 +354,61 @@
 	return open_socket(CLIENT_SOCKNAME, sizeof(CLIENT_SOCKNAME), privdata);
 }
 
+/* cman_wait_init
+ *
+ * @admin: set to 0 for standard socket, != 0 for admin socket
+ * @ctimeout: connection timeout in second to attempt to connect to cman.
+ *            0 = wait forever, -1 = do not wait.
+ * @qtimeout: cluster quorum timeout in second.
+ *            0 = wait forever, -1 = do not wait.
+ * @privdata: see cman_admin_init and cman_init.
+ */
+
+cman_handle_t cman_wait_init(int admin, int ctimeout, int qtimeout, void *privdata)
+{
+	cman_handle_t ch;
+	int i = 0;
+
+	if (!ctimeout)
+		i = 1;
+
+	while (ctimeout != i) {
+
+		if (admin) {
+			ch = cman_admin_init(privdata);
+		} else {
+			ch = cman_init(privdata);
+		}
+
+		if ((ch) || (ctimeout = -1)) {
+			i = ctimeout;
+		} else {
+			sleep(1);
+			i++;
+		}
+	}
+
+	if (!ch)
+		return ch;
+
+	if (!qtimeout) {
+		i = 1;
+	} else {
+		i = 0;
+	}
+
+	while (qtimeout != i) {
+		if ((cman_is_quorate(ch)) || (qtimeout = -1)) {
+			i = qtimeout;
+		} else {
+			sleep(1);
+			i++;
+		}
+	}
+
+	return ch;
+}
+
 int cman_finish(cman_handle_t handle)
 {
 	struct cman_handle *h = (struct cman_handle *)handle;
--- cluster/cman/lib/libcman.h	2007/11/05 15:15:53	1.35
+++ cluster/cman/lib/libcman.h	2007/11/05 16:43:50	1.36
@@ -203,6 +203,7 @@
  */
 cman_handle_t cman_init(void *privdata);
 cman_handle_t cman_admin_init(void *privdata);
+cman_handle_t cman_wait_init(int admin, int ctimeout, int qtimeout, void *privdata);
 int cman_finish(cman_handle_t handle);
 
 /* Update/retrieve the private data */


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