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
08c05da5
Commit
08c05da5
authored
Aug 31, 2011
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tdb2: unify tdb1_fetch into tdb_fetch
Switch on the TDB_VERSION1 flag.
parent
98c754ff
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
32 additions
and
30 deletions
+32
-30
ccan/tdb2/private.h
ccan/tdb2/private.h
+2
-0
ccan/tdb2/tdb.c
ccan/tdb2/tdb.c
+3
-0
ccan/tdb2/tdb1.h
ccan/tdb2/tdb1.h
+0
-2
ccan/tdb2/tdb1_tdb.c
ccan/tdb2/tdb1_tdb.c
+5
-4
ccan/tdb2/test/run-tdb1-3G-file.c
ccan/tdb2/test/run-tdb1-3G-file.c
+3
-3
ccan/tdb2/test/run-tdb1-endian.c
ccan/tdb2/test/run-tdb1-endian.c
+4
-4
ccan/tdb2/test/run-tdb1-incompatible.c
ccan/tdb2/test/run-tdb1-incompatible.c
+5
-5
ccan/tdb2/test/run-tdb1-nested-transactions.c
ccan/tdb2/test/run-tdb1-nested-transactions.c
+4
-4
ccan/tdb2/test/run-tdb1-zero-append.c
ccan/tdb2/test/run-tdb1-zero-append.c
+2
-2
ccan/tdb2/test/run-tdb1.c
ccan/tdb2/test/run-tdb1.c
+3
-4
ccan/tdb2/test/tdb1-external-agent.c
ccan/tdb2/test/tdb1-external-agent.c
+1
-2
No files found.
ccan/tdb2/private.h
View file @
08c05da5
...
...
@@ -648,6 +648,8 @@ int tdb1_transaction_cancel(struct tdb_context *tdb);
/* tdb1_tdb.c: */
int
tdb1_store
(
struct
tdb_context
*
tdb
,
TDB_DATA
key
,
TDB_DATA
dbuf
,
int
flag
);
enum
TDB_ERROR
tdb1_fetch
(
struct
tdb_context
*
tdb
,
TDB_DATA
key
,
TDB_DATA
*
data
);
/* tdb.c: */
enum
TDB_ERROR
COLD
tdb_logerr
(
struct
tdb_context
*
tdb
,
...
...
ccan/tdb2/tdb.c
View file @
08c05da5
...
...
@@ -248,6 +248,9 @@ enum TDB_ERROR tdb_fetch(struct tdb_context *tdb, struct tdb_data key,
struct
hash_info
h
;
enum
TDB_ERROR
ecode
;
if
(
tdb
->
flags
&
TDB_VERSION1
)
return
tdb1_fetch
(
tdb
,
key
,
data
);
off
=
find_and_lock
(
tdb
,
key
,
F_RDLCK
,
&
h
,
&
rec
,
NULL
);
if
(
TDB_OFF_IS_ERR
(
off
))
{
return
tdb
->
last_error
=
off
;
...
...
ccan/tdb2/tdb1.h
View file @
08c05da5
...
...
@@ -40,8 +40,6 @@ typedef int (*tdb1_traverse_func)(struct tdb_context *, TDB_DATA, TDB_DATA, void
void
tdb1_set_max_dead
(
struct
tdb_context
*
tdb
,
int
max_dead
);
TDB_DATA
tdb1_fetch
(
struct
tdb_context
*
tdb
,
TDB_DATA
key
);
int
tdb1_parse_record
(
struct
tdb_context
*
tdb
,
TDB_DATA
key
,
int
(
*
parser
)(
TDB_DATA
key
,
TDB_DATA
data
,
void
*
private_data
),
...
...
ccan/tdb2/tdb1_tdb.c
View file @
08c05da5
...
...
@@ -201,11 +201,12 @@ static TDB_DATA _tdb1_fetch(struct tdb_context *tdb, TDB_DATA key)
return
ret
;
}
TDB_DATA
tdb1_fetch
(
struct
tdb_context
*
tdb
,
TDB_DATA
key
)
enum
TDB_ERROR
tdb1_fetch
(
struct
tdb_context
*
tdb
,
TDB_DATA
key
,
TDB_DATA
*
data
)
{
TDB_DATA
ret
=
_tdb1_fetch
(
tdb
,
key
);
return
ret
;
*
data
=
_tdb1_fetch
(
tdb
,
key
);
if
(
data
->
dptr
==
NULL
)
return
tdb
->
last_error
;
return
TDB_SUCCESS
;
}
/*
...
...
ccan/tdb2/test/run-tdb1-3G-file.c
View file @
08c05da5
...
...
@@ -70,7 +70,7 @@ int main(int argc, char *argv[])
hsize
.
base
.
next
=
&
tap_log_attr
;
hsize
.
tdb1_hashsize
.
hsize
=
1024
;
plan_tests
(
2
4
);
plan_tests
(
2
6
);
tdb
=
tdb_open
(
"run-36-file.tdb1"
,
TDB_VERSION1
,
O_CREAT
|
O_TRUNC
|
O_RDWR
,
0600
,
&
hsize
);
...
...
@@ -88,7 +88,7 @@ int main(int argc, char *argv[])
ok1
(
tdb_store
(
tdb
,
key
,
orig_data
,
TDB_INSERT
)
==
TDB_SUCCESS
);
data
=
tdb1_fetch
(
tdb
,
key
);
ok1
(
tdb_fetch
(
tdb
,
key
,
&
data
)
==
TDB_SUCCESS
);
ok1
(
data
.
dsize
==
strlen
(
"world"
));
ok1
(
memcmp
(
data
.
dptr
,
"world"
,
strlen
(
"world"
))
==
0
);
free
(
data
.
dptr
);
...
...
@@ -112,7 +112,7 @@ int main(int argc, char *argv[])
ok1
(
tdb1_transaction_start
(
tdb
)
==
0
);
ok1
(
tdb_store
(
tdb
,
key
,
orig_data
,
TDB_INSERT
)
==
TDB_SUCCESS
);
data
=
tdb1_fetch
(
tdb
,
key
);
ok1
(
tdb_fetch
(
tdb
,
key
,
&
data
)
==
TDB_SUCCESS
);
ok1
(
data
.
dsize
==
strlen
(
"world"
));
ok1
(
memcmp
(
data
.
dptr
,
"world"
,
strlen
(
"world"
))
==
0
);
free
(
data
.
dptr
);
...
...
ccan/tdb2/test/run-tdb1-endian.c
View file @
08c05da5
...
...
@@ -14,7 +14,7 @@ int main(int argc, char *argv[])
hsize
.
base
.
next
=
&
tap_log_attr
;
hsize
.
tdb1_hashsize
.
hsize
=
1024
;
plan_tests
(
1
1
);
plan_tests
(
1
4
);
tdb
=
tdb_open
(
"run-endian.tdb1"
,
TDB_VERSION1
|
TDB_CONVERT
,
O_CREAT
|
O_TRUNC
|
O_RDWR
,
0600
,
&
hsize
);
...
...
@@ -30,13 +30,13 @@ int main(int argc, char *argv[])
ok1
(
tdb_store
(
tdb
,
key
,
data
,
TDB_INSERT
)
==
TDB_ERR_EXISTS
);
ok1
(
tdb_store
(
tdb
,
key
,
data
,
TDB_MODIFY
)
==
TDB_SUCCESS
);
data
=
tdb1_fetch
(
tdb
,
key
);
ok1
(
tdb_fetch
(
tdb
,
key
,
&
data
)
==
TDB_SUCCESS
);
ok1
(
data
.
dsize
==
strlen
(
"world"
));
ok1
(
memcmp
(
data
.
dptr
,
"world"
,
strlen
(
"world"
))
==
0
);
free
(
data
.
dptr
);
key
.
dsize
++
;
data
=
tdb1_fetch
(
tdb
,
key
);
ok1
(
tdb_fetch
(
tdb
,
key
,
&
data
)
==
TDB_ERR_NOEXIST
);
ok1
(
data
.
dptr
==
NULL
);
tdb_close
(
tdb
);
...
...
@@ -46,7 +46,7 @@ int main(int argc, char *argv[])
key
.
dsize
=
strlen
(
"hi"
);
key
.
dptr
=
(
void
*
)
"hi"
;
data
=
tdb1_fetch
(
tdb
,
key
);
ok1
(
tdb_fetch
(
tdb
,
key
,
&
data
)
==
TDB_SUCCESS
);
ok1
(
data
.
dsize
==
strlen
(
"world"
));
ok1
(
memcmp
(
data
.
dptr
,
"world"
,
strlen
(
"world"
))
==
0
);
free
(
data
.
dptr
);
...
...
ccan/tdb2/test/run-tdb1-incompatible.c
View file @
08c05da5
...
...
@@ -73,7 +73,7 @@ int main(int argc, char *argv[])
dumbhash_attr
.
base
.
next
=
&
log_attr
;
dumbhash_attr
.
hash
.
fn
=
tdb1_dumb_hash
;
plan_tests
(
38
*
2
);
plan_tests
(
42
*
2
);
for
(
flags
=
0
;
flags
<=
TDB_CONVERT
;
flags
+=
TDB_CONVERT
)
{
unsigned
int
rwmagic
=
TDB1_HASH_RWLOCK_MAGIC
;
...
...
@@ -102,7 +102,7 @@ int main(int argc, char *argv[])
O_RDWR
,
0600
,
&
incompat_hash_attr
);
ok1
(
tdb
);
ok1
(
log_count
==
0
);
d
=
tdb1_fetch
(
tdb
,
d
);
ok1
(
tdb_fetch
(
tdb
,
d
,
&
d
)
==
TDB_SUCCESS
);
ok1
(
d
.
dsize
==
5
);
free
(
d
.
dptr
);
ok1
(
tdb1_check
(
tdb
,
NULL
,
NULL
)
==
0
);
...
...
@@ -153,7 +153,7 @@ int main(int argc, char *argv[])
O_RDWR
,
0600
,
&
jhash_attr
);
ok1
(
tdb
);
ok1
(
log_count
==
0
);
d
=
tdb1_fetch
(
tdb
,
d
);
ok1
(
tdb1_fetch
(
tdb
,
d
,
&
d
)
==
TDB_SUCCESS
);
ok1
(
d
.
dsize
==
5
);
free
(
d
.
dptr
);
ok1
(
tdb1_check
(
tdb
,
NULL
,
NULL
)
==
0
);
...
...
@@ -167,7 +167,7 @@ int main(int argc, char *argv[])
ok1
(
log_count
==
0
);
d
.
dptr
=
(
void
*
)
"Hello"
;
d
.
dsize
=
5
;
d
=
tdb1_fetch
(
tdb
,
d
);
ok1
(
tdb_fetch
(
tdb
,
d
,
&
d
)
==
TDB_SUCCESS
);
ok1
(
d
.
dsize
==
5
);
free
(
d
.
dptr
);
ok1
(
tdb1_check
(
tdb
,
NULL
,
NULL
)
==
0
);
...
...
@@ -202,7 +202,7 @@ int main(int argc, char *argv[])
&
dumbhash_attr
);
ok1
(
tdb
);
ok1
(
log_count
==
0
);
d
=
tdb1_fetch
(
tdb
,
d
);
ok1
(
tdb1_fetch
(
tdb
,
d
,
&
d
)
==
TDB_SUCCESS
);
ok1
(
d
.
dsize
==
5
);
free
(
d
.
dptr
);
ok1
(
tdb1_check
(
tdb
,
NULL
,
NULL
)
==
0
);
...
...
ccan/tdb2/test/run-tdb1-nested-transactions.c
View file @
08c05da5
...
...
@@ -15,7 +15,7 @@ int main(int argc, char *argv[])
hsize
.
base
.
next
=
&
tap_log_attr
;
hsize
.
tdb1_hashsize
.
hsize
=
1024
;
plan_tests
(
27
);
plan_tests
(
30
);
key
.
dsize
=
strlen
(
"hi"
);
key
.
dptr
=
(
void
*
)
"hi"
;
...
...
@@ -28,19 +28,19 @@ int main(int argc, char *argv[])
data
.
dptr
=
(
void
*
)
"world"
;
data
.
dsize
=
strlen
(
"world"
);
ok1
(
tdb_store
(
tdb
,
key
,
data
,
TDB_INSERT
)
==
TDB_SUCCESS
);
data
=
tdb1_fetch
(
tdb
,
key
);
ok1
(
tdb_fetch
(
tdb
,
key
,
&
data
)
==
TDB_SUCCESS
);
ok1
(
data
.
dsize
==
strlen
(
"world"
));
ok1
(
memcmp
(
data
.
dptr
,
"world"
,
strlen
(
"world"
))
==
0
);
free
(
data
.
dptr
);
ok1
(
tdb1_transaction_start
(
tdb
)
!=
0
);
ok1
(
tdb_error
(
tdb
)
==
TDB_ERR_EINVAL
);
data
=
tdb1_fetch
(
tdb
,
key
);
ok1
(
tdb_fetch
(
tdb
,
key
,
&
data
)
==
TDB_SUCCESS
);
ok1
(
data
.
dsize
==
strlen
(
"world"
));
ok1
(
memcmp
(
data
.
dptr
,
"world"
,
strlen
(
"world"
))
==
0
);
free
(
data
.
dptr
);
ok1
(
tdb1_transaction_commit
(
tdb
)
==
0
);
data
=
tdb1_fetch
(
tdb
,
key
);
ok1
(
tdb_fetch
(
tdb
,
key
,
&
data
)
==
TDB_SUCCESS
);
ok1
(
data
.
dsize
==
strlen
(
"world"
));
ok1
(
memcmp
(
data
.
dptr
,
"world"
,
strlen
(
"world"
))
==
0
);
free
(
data
.
dptr
);
...
...
ccan/tdb2/test/run-tdb1-zero-append.c
View file @
08c05da5
...
...
@@ -14,7 +14,7 @@ int main(int argc, char *argv[])
hsize
.
base
.
next
=
&
tap_log_attr
;
hsize
.
tdb1_hashsize
.
hsize
=
1024
;
plan_tests
(
4
);
plan_tests
(
5
);
tdb
=
tdb_open
(
NULL
,
TDB_INTERNAL
|
TDB_VERSION1
,
O_CREAT
|
O_TRUNC
|
O_RDWR
,
0600
,
&
hsize
);
ok1
(
tdb
);
...
...
@@ -27,7 +27,7 @@ int main(int argc, char *argv[])
ok1
(
tdb1_append
(
tdb
,
key
,
data
)
==
0
);
ok1
(
tdb1_append
(
tdb
,
key
,
data
)
==
0
);
data
=
tdb1_fetch
(
tdb
,
key
);
ok1
(
tdb_fetch
(
tdb
,
key
,
&
data
)
==
TDB_SUCCESS
);
ok1
(
data
.
dsize
==
0
);
free
(
data
.
dptr
);
tdb_close
(
tdb
);
...
...
ccan/tdb2/test/run-tdb1.c
View file @
08c05da5
...
...
@@ -14,7 +14,7 @@ int main(int argc, char *argv[])
hsize
.
base
.
next
=
&
tap_log_attr
;
hsize
.
tdb1_hashsize
.
hsize
=
1024
;
plan_tests
(
8
);
plan_tests
(
9
);
tdb
=
tdb_open
(
"run.tdb1"
,
TDB_VERSION1
,
O_CREAT
|
O_TRUNC
|
O_RDWR
,
0600
,
&
hsize
);
...
...
@@ -29,14 +29,13 @@ int main(int argc, char *argv[])
ok1
(
tdb_store
(
tdb
,
key
,
data
,
TDB_INSERT
)
==
TDB_ERR_EXISTS
);
ok1
(
tdb_store
(
tdb
,
key
,
data
,
TDB_MODIFY
)
==
TDB_SUCCESS
);
data
=
tdb1_fetch
(
tdb
,
key
);
ok1
(
tdb_fetch
(
tdb
,
key
,
&
data
)
==
TDB_SUCCESS
);
ok1
(
data
.
dsize
==
strlen
(
"world"
));
ok1
(
memcmp
(
data
.
dptr
,
"world"
,
strlen
(
"world"
))
==
0
);
free
(
data
.
dptr
);
key
.
dsize
++
;
data
=
tdb1_fetch
(
tdb
,
key
);
ok1
(
data
.
dptr
==
NULL
);
ok1
(
tdb_fetch
(
tdb
,
key
,
&
data
)
==
TDB_ERR_NOEXIST
);
tdb_close
(
tdb
);
return
exit_status
();
...
...
ccan/tdb2/test/tdb1-external-agent.c
View file @
08c05da5
...
...
@@ -51,8 +51,7 @@ static enum agent_return do_operation(enum operation op, const char *name)
ret
=
tdb1_transaction_start
(
tdb
)
==
0
?
SUCCESS
:
OTHER_FAILURE
;
break
;
case
FETCH
:
data
=
tdb1_fetch
(
tdb
,
k
);
if
(
data
.
dptr
==
NULL
)
{
if
(
tdb_fetch
(
tdb
,
k
,
&
data
)
!=
TDB_SUCCESS
)
{
if
(
tdb
->
last_error
==
TDB_ERR_NOEXIST
)
ret
=
FAILED
;
else
...
...
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