All of lore.kernel.org
 help / color / mirror / Atom feed
From: pcaulfield@sourceware.org <pcaulfield@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/dlm/tests/usertest flood.c
Date: 18 Jul 2007 15:13:27 -0000	[thread overview]
Message-ID: <20070718151327.20411.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	STABLE
Changes by:	pcaulfield at sourceware.org	2007-07-18 15:13:26

Modified files:
	dlm/tests/usertest: flood.c 

Log message:
	Add timeout

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tests/usertest/flood.c.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.1.2.2&r2=1.1.2.3

--- cluster/dlm/tests/usertest/flood.c	2005/12/19 16:43:59	1.1.2.2
+++ cluster/dlm/tests/usertest/flood.c	2007/07/18 15:13:26	1.1.2.3
@@ -37,6 +37,7 @@
     fprintf(file, "   -m <num>   Maximum number of locks to hold (default MAX_INT)\n");
     fprintf(file, "   -i <num>   Show progress in <n> increments (default 1000)\n");
     fprintf(file, "   -n <num>   Number of resources (default 10)\n");
+    fprintf(file, "   -t <secs>  Seconds to run for\n");
     fprintf(file, "   -q         Quit\n");
 
 
@@ -49,15 +50,20 @@
     struct dlm_lksb *lksb = arg;
 
     if (lksb->sb_status == 0) {
+	if (lksb->sb_lkid & 0x80000000) {
+		fprintf(stderr, "got -ve lock ID : %x\n", lksb->sb_lkid);
+	}
 	dlm_unlock(lksb->sb_lkid, 0, lksb, lksb);
 	return;
     }
 
     if (lksb->sb_status == EUNLOCK) {
 	    count--;
-	    free(lksb);
+	    //free(lksb);
+	    return;
     }
-
+    fprintf(stderr, "lock failed: %s\n", strerror(lksb->sb_status));
+    exit(1);
 }
 
 int main(int argc, char *argv[])
@@ -68,16 +74,19 @@
     int  rescount = 10;
     int  increment = 1000;
     int  quiet = 0;
+    int  runtime = 0;
     int  status;
     int  i;
     int  mode = LKM_CRMODE;
     signed char opt;
     char **resources;
+    clock_t start;
+    time_t starttime;
 
     /* Deal with command-line arguments */
     opterr = 0;
     optind = 0;
-    while ((opt=getopt(argc,argv,"?m:i:qn:vV")) != EOF)
+    while ((opt=getopt(argc,argv,"?m:i:qn:t:vV")) != EOF)
     {
 	switch(opt)
 	{
@@ -101,6 +110,10 @@
 	    rescount = atoi(optarg);
 	    break;
 
+	case 't':
+	    runtime = atoi(optarg);
+	    break;
+
 	case 'q':
 	    quiet = 1;
 	    break;
@@ -124,10 +137,12 @@
     pthread_mutex_lock(&mutex);
 
     dlm_pthread_init();
+    start = times(NULL);
 
-    while (1) {
+    starttime = time(NULL);
+    while (runtime?(time(NULL)-starttime<runtime):1) {
 	    char *resource = resources[rand() % rescount];
-	    struct dlm_lksb *lksb = malloc(sizeof(struct dlm_lksb));
+	    struct dlm_lksb *lksb = malloc(sizeof(struct dlm_lksb)+64);
 	    if (!lksb)
 		    exit(1);
 
@@ -150,13 +165,19 @@
 	    count++;
 	    lockops++;
 	    if ((lockops % increment) == 0 && !quiet)
-		    fprintf(stderr, "%d lockops, %d locks\n", lockops, count);
+	    {
+		    fprintf(stderr, "%d lockops, %d locks. Time = %ld\n", lockops, count,
+				times(NULL)-start);
+    		    start = times(NULL);
+	    }
 
 	    while (count > maxlocks) {
 		    sleep(1);
 	    }
 
     }
+    if (runtime)
+	printf("finished %d lock operations\n", lockops);
 
     return 0;
 }



             reply	other threads:[~2007-07-18 15:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-18 15:13 pcaulfield [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-03-27 15:17 [Cluster-devel] cluster/dlm/tests/usertest flood.c pcaulfield
2007-03-27 15:02 pcaulfield

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=20070718151327.20411.qmail@sourceware.org \
    --to=pcaulfield@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.