diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-07-09 10:18:02 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-07-09 10:18:02 +0300 |
commit | 0eafbb93c82a489204f54259593f2aaeb9cdbfc4 (patch) | |
tree | e7fad3689d9110d7132ee2fe5f9bdcc2011474ef /src/gdbmseq.c | |
parent | e4d2c56435a23ce1d3a0c06518231f632311de04 (diff) | |
download | gdbm-0eafbb93c82a489204f54259593f2aaeb9cdbfc4.tar.gz gdbm-0eafbb93c82a489204f54259593f2aaeb9cdbfc4.tar.bz2 |
All gdbm functions return immediately if the DB is in inconsistent sate (needs recovery).
* src/gdbm.h.in (GDBM_NEED_RECOVERY): New error code.
* src/gdbmdefs.h (GDBM_ASSERT_CONSISTENCY): New macro.
* src/gdbmerrno.c: Update.
* src/gdbmopen.c (gdbm_open): Initialize need_recovery
and last_error.
* src/gdbmcount.c (gdbm_count): Return immediately if the
database needs recovery.
* src/gdbmdelete.c (gdbm_delete): Likewise.
* src/gdbmdump.c (gdbm_dump_to_file, gdbm_dump): Likewise.
* src/gdbmexists.c (gdbm_exists): Likewise.
* src/gdbmexp.c (gdbm_export_to_file): Likewise.
* src/gdbmfetch.c (gdbm_fetch): Likewise.
* src/gdbmimp.c (gdbm_import_from_file): Likewise.
* src/gdbmreorg.c (gdbm_reorganize): Likewise.
* src/gdbmseq.c (gdbm_firstkey): Likewise.
* src/gdbmsetopt.c (gdbm_nextkey): Likewise.
* src/gdbmstore.c (gdbm_store): Likewise.
* src/gdbmsync.c (gdbm_sync): Likewise.
Diffstat (limited to 'src/gdbmseq.c')
-rw-r--r-- | src/gdbmseq.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/gdbmseq.c b/src/gdbmseq.c index c62a13b..831339a 100644 --- a/src/gdbmseq.c +++ b/src/gdbmseq.c @@ -100,6 +100,9 @@ gdbm_firstkey (GDBM_FILE dbf) /* Set the default return value for not finding a first entry. */ return_val.dptr = NULL; + /* Return immediately if the database needs recovery */ + GDBM_ASSERT_CONSISTENCY (dbf, return_val); + /* Initialize the gdbm_errno variable. */ gdbm_set_errno (dbf, GDBM_NO_ERROR, 0); @@ -121,12 +124,15 @@ gdbm_nextkey (GDBM_FILE dbf, datum key) datum return_val; /* The return value. */ int elem_loc; /* The location in the bucket. */ - /* Initialize the gdbm_errno variable. */ - gdbm_set_errno (dbf, GDBM_NO_ERROR, 0); - /* Set the default return value for no next entry. */ return_val.dptr = NULL; + /* Return immediately if the database needs recovery */ + GDBM_ASSERT_CONSISTENCY (dbf, return_val); + + /* Initialize the gdbm_errno variable. */ + gdbm_set_errno (dbf, GDBM_NO_ERROR, 0); + /* Do we have a valid key? */ if (key.dptr == NULL) { |