All of lore.kernel.org
 help / color / mirror / Atom feed
From: teigland@sourceware.org <teigland@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/dlm/tests/usertest Makefile joinleave.c
Date: 31 Jan 2007 22:47:00 -0000	[thread overview]
Message-ID: <20070131224700.8473.qmail@sourceware.org> (raw)

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
 



                 reply	other threads:[~2007-01-31 22:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070131224700.8473.qmail@sourceware.org \
    --to=teigland@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.