From: pcaulfield@sourceware.org <pcaulfield@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/dlm/tests/usertest flood.c
Date: 27 Mar 2007 15:02:43 -0000 [thread overview]
Message-ID: <20070327150243.13597.qmail@sourceware.org> (raw)
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;
next reply other threads:[~2007-03-27 15:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-27 15:02 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-07-18 15:13 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=20070327150243.13597.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 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).