Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccan
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mirror
ccan
Commits
6f74ace3
Commit
6f74ace3
authored
Oct 19, 2009
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tdb: add -t (always transactional) to tdbtorture
parent
dea5ab34
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
12 deletions
+28
-12
ccan/tdb/tools/tdbtorture.c
ccan/tdb/tools/tdbtorture.c
+28
-12
No files found.
ccan/tdb/tools/tdbtorture.c
View file @
6f74ace3
...
@@ -35,6 +35,7 @@ static struct tdb_context *db;
...
@@ -35,6 +35,7 @@ static struct tdb_context *db;
static
int
in_transaction
;
static
int
in_transaction
;
static
int
in_traverse
;
static
int
in_traverse
;
static
int
error_count
;
static
int
error_count
;
static
int
always_transaction
=
0
;
#ifdef PRINTF_ATTRIBUTE
#ifdef PRINTF_ATTRIBUTE
static
void
tdb_log
(
struct
tdb_context
*
tdb
,
enum
tdb_debug_level
level
,
const
char
*
format
,
...)
PRINTF_ATTRIBUTE
(
3
,
4
);
static
void
tdb_log
(
struct
tdb_context
*
tdb
,
enum
tdb_debug_level
level
,
const
char
*
format
,
...)
PRINTF_ATTRIBUTE
(
3
,
4
);
...
@@ -120,8 +121,15 @@ static void addrec_db(void)
...
@@ -120,8 +121,15 @@ static void addrec_db(void)
data
.
dptr
=
(
unsigned
char
*
)
d
;
data
.
dptr
=
(
unsigned
char
*
)
d
;
data
.
dsize
=
dlen
+
1
;
data
.
dsize
=
dlen
+
1
;
#if REOPEN_PROB
if
(
in_traverse
==
0
&&
in_transaction
==
0
&&
random
()
%
REOPEN_PROB
==
0
)
{
tdb_reopen_all
(
0
);
goto
next
;
}
#endif
#if TRANSACTION_PROB
#if TRANSACTION_PROB
if
(
in_traverse
==
0
&&
in_transaction
==
0
&&
random
()
%
TRANSACTION_PROB
==
0
)
{
if
(
in_traverse
==
0
&&
in_transaction
==
0
&&
(
always_transaction
||
random
()
%
TRANSACTION_PROB
==
0
)
)
{
if
(
tdb_transaction_start
(
db
)
!=
0
)
{
if
(
tdb_transaction_start
(
db
)
!=
0
)
{
fatal
(
"tdb_transaction_start failed"
);
fatal
(
"tdb_transaction_start failed"
);
}
}
...
@@ -150,13 +158,6 @@ static void addrec_db(void)
...
@@ -150,13 +158,6 @@ static void addrec_db(void)
}
}
#endif
#endif
#if REOPEN_PROB
if
(
in_traverse
==
0
&&
in_transaction
==
0
&&
random
()
%
REOPEN_PROB
==
0
)
{
tdb_reopen_all
(
0
);
goto
next
;
}
#endif
#if DELETE_PROB
#if DELETE_PROB
if
(
random
()
%
DELETE_PROB
==
0
)
{
if
(
random
()
%
DELETE_PROB
==
0
)
{
tdb_delete
(
db
,
key
);
tdb_delete
(
db
,
key
);
...
@@ -231,7 +232,7 @@ static int traverse_fn(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf,
...
@@ -231,7 +232,7 @@ static int traverse_fn(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf,
static
void
usage
(
void
)
static
void
usage
(
void
)
{
{
printf
(
"Usage: tdbtorture [-n NUM_PROCS] [-l NUM_LOOPS] [-s SEED] [-H HASH_SIZE]
\n
"
);
printf
(
"Usage: tdbtorture [-
t] [-
n NUM_PROCS] [-l NUM_LOOPS] [-s SEED] [-H HASH_SIZE]
\n
"
);
exit
(
0
);
exit
(
0
);
}
}
...
@@ -248,7 +249,7 @@ int main(int argc, char * const *argv)
...
@@ -248,7 +249,7 @@ int main(int argc, char * const *argv)
struct
tdb_logging_context
log_ctx
;
struct
tdb_logging_context
log_ctx
;
log_ctx
.
log_fn
=
tdb_log
;
log_ctx
.
log_fn
=
tdb_log
;
while
((
c
=
getopt
(
argc
,
argv
,
"n:l:s:H:h"
))
!=
-
1
)
{
while
((
c
=
getopt
(
argc
,
argv
,
"n:l:s:H:
t
h"
))
!=
-
1
)
{
switch
(
c
)
{
switch
(
c
)
{
case
'n'
:
case
'n'
:
num_procs
=
strtol
(
optarg
,
NULL
,
0
);
num_procs
=
strtol
(
optarg
,
NULL
,
0
);
...
@@ -262,6 +263,9 @@ int main(int argc, char * const *argv)
...
@@ -262,6 +263,9 @@ int main(int argc, char * const *argv)
case
's'
:
case
's'
:
seed
=
strtol
(
optarg
,
NULL
,
0
);
seed
=
strtol
(
optarg
,
NULL
,
0
);
break
;
break
;
case
't'
:
always_transaction
=
1
;
break
;
default:
default:
usage
();
usage
();
}
}
...
@@ -287,8 +291,8 @@ int main(int argc, char * const *argv)
...
@@ -287,8 +291,8 @@ int main(int argc, char * const *argv)
}
}
if
(
i
==
0
)
{
if
(
i
==
0
)
{
printf
(
"testing with %d processes, %d loops, %d hash_size, seed=%d
\n
"
,
printf
(
"testing with %d processes, %d loops, %d hash_size, seed=%d
%s
\n
"
,
num_procs
,
num_loops
,
hash_size
,
seed
);
num_procs
,
num_loops
,
hash_size
,
seed
,
always_transaction
?
" (all within transactions)"
:
""
);
}
}
srand
(
seed
+
i
);
srand
(
seed
+
i
);
...
@@ -300,8 +304,20 @@ int main(int argc, char * const *argv)
...
@@ -300,8 +304,20 @@ int main(int argc, char * const *argv)
if
(
error_count
==
0
)
{
if
(
error_count
==
0
)
{
tdb_traverse_read
(
db
,
NULL
,
NULL
);
tdb_traverse_read
(
db
,
NULL
,
NULL
);
if
(
always_transaction
)
{
while
(
in_transaction
)
{
tdb_transaction_cancel
(
db
);
in_transaction
--
;
}
if
(
tdb_transaction_start
(
db
)
!=
0
)
fatal
(
"tdb_transaction_start failed"
);
}
tdb_traverse
(
db
,
traverse_fn
,
NULL
);
tdb_traverse
(
db
,
traverse_fn
,
NULL
);
tdb_traverse
(
db
,
traverse_fn
,
NULL
);
tdb_traverse
(
db
,
traverse_fn
,
NULL
);
if
(
always_transaction
)
{
if
(
tdb_transaction_commit
(
db
)
!=
0
)
fatal
(
"tdb_transaction_commit failed"
);
}
}
}
tdb_close
(
db
);
tdb_close
(
db
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment