cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] cluster/dlm/tests/usertest Makefile joinleave.c
@ 2007-01-31 22:47 teigland
  0 siblings, 0 replies; only message in thread
From: teigland @ 2007-01-31 22:47 UTC (permalink / raw)
  To: cluster-devel.redhat.com

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	teigland at sourceware.org	2007-01-31 22:47:00

Modified files:
	dlm/tests/usertest: Makefile 
Added files:
	dlm/tests/usertest: joinleave.c 

Log message:
	join lockspace, optionally sleep, leave the lockspace.
	useful for testing, also useful to clear/release a lockspace
	from any random process that exited without releasing its lockspace

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tests/usertest/joinleave.c.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tests/usertest/Makefile.diff?cvsroot=cluster&r1=1.8&r2=1.9

/cvs/cluster/cluster/dlm/tests/usertest/joinleave.c,v  -->  standard output
revision 1.1
--- cluster/dlm/tests/usertest/joinleave.c
+++ -	2007-01-31 22:47:00.651392000 +0000
@@ -0,0 +1,62 @@
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <stddef.h>
+#include <errno.h>
+#include <time.h>
+#include <sys/time.h>
+#include <syslog.h>
+#include <sys/types.h>
+#include <sys/errno.h>
+
+#include "libdlm.h"
+
+static dlm_lshandle_t *dh;
+
+int main(int argc, char *argv[])
+{
+	struct timeval begin, end, diff;
+	char *name;
+	int sec = 0;
+
+	if (argc < 2) {
+		printf("%s <lockspace name> [sleep sec]\n", argv[0]);
+		exit(-1);
+	}
+
+	name = argv[1];
+
+	if (argc > 2)
+		sec = atoi(argv[2]);
+
+	printf("Joining lockspace \"%s\" ... ", name);
+	fflush(stdout);
+
+	gettimeofday(&begin, NULL);
+	dh = dlm_create_lockspace(name, 0600);
+	if (!dh) {
+		printf("dlm_create_lockspace error %d %d\n", (int) dh, errno);
+		return -ENOTCONN;
+	}
+	gettimeofday(&end, NULL);
+
+	timersub(&end, &begin, &diff);
+	printf("%lu s\n", diff.tv_sec);
+
+	if (sec)
+		sleep(sec);
+
+	printf("Leaving lockspace \"%s\" ... ", name);
+	fflush(stdout);
+
+	gettimeofday(&begin, NULL);
+	dlm_release_lockspace(name, dh, 1);
+	gettimeofday(&end, NULL);
+
+	timersub(&end, &begin, &diff);
+	printf("%lu s\n", diff.tv_sec);
+
+	return 0;
+}
+
--- cluster/dlm/tests/usertest/Makefile	2007/01/31 18:47:41	1.8
+++ cluster/dlm/tests/usertest/Makefile	2007/01/31 22:47:00	1.9
@@ -12,7 +12,7 @@
 top_srcdir = ../../..
 UNINSTALL=${top_srcdir}/scripts/uninstall.pl
 
-BINARIES=dlmtest asttest lstest pingtest lvb dlmtest2 flood alternate-lvb
+BINARIES=dlmtest asttest lstest pingtest lvb dlmtest2 flood alternate-lvb joinleave
 
 all: $(BINARIES)
 
@@ -35,6 +35,9 @@
 alternate-lvb: alternate-lvb.c
 	$(CC) $(CFLAGS) -o $@ $< -ldlm -lpthread
 
+joinleave: joinleave.c
+	$(CC) $(CFLAGS) -Wall -o $@ $< -ldlm -lpthread
+
 flood: flood.c
 	$(CC) $(CFLAGS) -o $@ $< -ldlm -lpthread
 



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-01-31 22:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-31 22:47 [Cluster-devel] cluster/dlm/tests/usertest Makefile joinleave.c teigland

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).