* [Cluster-devel] cluster/dlm/tests/usertest flood.c
@ 2007-03-27 15:02 pcaulfield
0 siblings, 0 replies; 3+ messages in thread
From: pcaulfield @ 2007-03-27 15:02 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: pcaulfield at sourceware.org 2007-03-27 16:02:42
Modified files:
dlm/tests/usertest: flood.c
Log message:
Fix bug where we could free an lksb while dlm_lock is still using it.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tests/usertest/flood.c.diff?cvsroot=cluster&r1=1.2&r2=1.3
--- cluster/dlm/tests/usertest/flood.c 2007/01/09 14:17:37 1.2
+++ cluster/dlm/tests/usertest/flood.c 2007/03/27 15:02:42 1.3
@@ -55,9 +55,7 @@
if (lksb->sb_status == EUNLOCK) {
count--;
- free(lksb);
}
-
}
int main(int argc, char *argv[])
@@ -71,8 +69,10 @@
int status;
int i;
int mode = LKM_CRMODE;
+ int lksbnum = 0;
signed char opt;
char **resources;
+ struct dlm_lksb *lksbs;
/* Deal with command-line arguments */
opterr = 0;
@@ -106,7 +106,7 @@
break;
case 'V':
- printf("\nflood version 0.2\n\n");
+ printf("\nflood version 0.3\n\n");
exit(1);
break;
}
@@ -119,6 +119,13 @@
resources[i] = strdup(resname);
}
+ lksbs = malloc(sizeof(struct dlm_lksb) * maxlocks);
+ if (!lksbs)
+ {
+ perror("cannot allocate lksbs");
+ return 1;
+ }
+
pthread_cond_init(&cond, NULL);
pthread_mutex_init(&mutex, NULL);
pthread_mutex_lock(&mutex);
@@ -127,18 +134,15 @@
while (1) {
char *resource = resources[rand() % rescount];
- struct dlm_lksb *lksb = malloc(sizeof(struct dlm_lksb));
- if (!lksb)
- exit(1);
status = dlm_lock(mode,
- lksb,
+ &lksbs[lksbnum],
flags,
resource,
strlen(resource),
0, // Parent,
ast_routine,
- lksb,
+ &lksbs[lksbnum],
NULL, // bast_routine,
NULL); // Range
if (status == -1)
@@ -155,7 +159,7 @@
while (count > maxlocks) {
sleep(1);
}
-
+ lksbnum = (lksbnum+1)%maxlocks;
}
return 0;
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Cluster-devel] cluster/dlm/tests/usertest flood.c
@ 2007-03-27 15:17 pcaulfield
0 siblings, 0 replies; 3+ messages in thread
From: pcaulfield @ 2007-03-27 15:17 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: pcaulfield at sourceware.org 2007-03-27 16:17:03
Modified files:
dlm/tests/usertest: flood.c
Log message:
Actually, MAX_INT is a bit of a bad idea under this new system.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tests/usertest/flood.c.diff?cvsroot=cluster&r1=1.3&r2=1.4
--- cluster/dlm/tests/usertest/flood.c 2007/03/27 15:02:42 1.3
+++ cluster/dlm/tests/usertest/flood.c 2007/03/27 15:17:03 1.4
@@ -34,7 +34,7 @@
fprintf(file, "\n");
fprintf(file, " -V Show version of %s\n", prog);
fprintf(file, " -h Show this help information\n");
- fprintf(file, " -m <num> Maximum number of locks to hold (default MAX_INT)\n");
+ fprintf(file, " -m <num> Maximum number of locks to hold (default 100000)\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, " -q Quit\n");
@@ -62,7 +62,7 @@
{
int flags = 0;
int lockops = 0;
- int maxlocks = INT_MAX;
+ int maxlocks = 100000;
int rescount = 10;
int increment = 1000;
int quiet = 0;
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Cluster-devel] cluster/dlm/tests/usertest flood.c
@ 2007-07-18 15:13 pcaulfield
0 siblings, 0 replies; 3+ messages in thread
From: pcaulfield @ 2007-07-18 15:13 UTC (permalink / raw)
To: cluster-devel.redhat.com
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;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-07-18 15:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-18 15:13 [Cluster-devel] cluster/dlm/tests/usertest flood.c pcaulfield
-- strict thread matches above, loose matches on Subject: below --
2007-03-27 15:17 pcaulfield
2007-03-27 15:02 pcaulfield
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).