summaryrefslogtreecommitdiffabout
path: root/src/gdbmstore.c
authorSergey Poznyakoff <gray@gnu.org>2016-07-20 11:40:08 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2016-07-20 11:50:21 (GMT)
commitde7834e96602695db1cb6efd6238398b84d2ca60 (patch) (side-by-side diff)
tree2fc49853a76d68a8db11aab24017843102fd22a8 /src/gdbmstore.c
parentfbb0df69ca498a4fb4689a6d12c2f05e2cfaf175 (diff)
downloadgdbm-de7834e96602695db1cb6efd6238398b84d2ca60.tar.gz
gdbm-de7834e96602695db1cb6efd6238398b84d2ca60.tar.bz2
Introduce debug hooks.
* configure.ac: New option --enable-debug Print feature summary at the end of the run. * src/debug.c: New file. * src/Makefile.am [GDBM_COND_DEBUG_ENABLE]: Build debug.o Define GDBM_DEBUG_ENABLE. * src/gdbmdefs.h [GDBM_DEBUG_ENABLE] (_gdbm_debug_hook_install) (_gdbm_debug_hook_remove,_gdbm_debug_hook_check) (_gdbm_debug_hook_val): New protos. (GDBM_DEBUG_HOOK, GDBM_DEBUG_OVERRIDE) (GDBM_DEBUG_ALLOC): New defines. * src/gdbm.h.in (GDBM_RCVR_FORCE): New flag. * src/recover.c (gdbm_recover): Check database before attempting recovery, unless GDBM_RCVR_FORCE flag is set. * doc/gdbm.texi: Document GDBM_RCVR_FORCE * src/gdbmreorg.c (gdbm_reorganize): Use GDBM_RCVR_FORCE. * src/gdbmtool.c (main): Always allocate file_name. * src/bucket.c: Put GDBM_DEBUG_OVERRIDE and GDBM_DEBUG_ALLOC in critical places. * src/falloc.c: Likewise. * src/findkey.c: Likewise. * src/gdbmopen.c: Likewise. * src/gdbmstore.c: Likewise. * src/update.c: Likewise. * tests/Makefile.am [GDBM_COND_DEBUG_ENABLE]: Define GDBM_DEBUG_ENABLE. * tests/gtload.c: New options -hook, -recover, -verbose, -backup, -max-failures, -max-failed-keys, and -max-failed-buckets. Attempt recovery after errors.
Diffstat (limited to 'src/gdbmstore.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/gdbmstore.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/gdbmstore.c b/src/gdbmstore.c
index 7aec604..1d7c648 100644
--- a/src/gdbmstore.c
+++ b/src/gdbmstore.c
@@ -144,7 +144,8 @@ gdbm_store (GDBM_FILE dbf, datum key, datum content, int flags)
dbf->bucket->h_table[elem_loc].data_size = content.dsize;
/* Write the data to the file. */
- file_pos = __lseek (dbf, file_adr, SEEK_SET);
+ file_pos = GDBM_DEBUG_OVERRIDE ("gdbm_store:seek-failure",
+ __lseek (dbf, file_adr, SEEK_SET));
if (file_pos != file_adr)
{
gdbm_set_errno (dbf, GDBM_FILE_SEEK_ERROR, TRUE);
@@ -152,7 +153,8 @@ gdbm_store (GDBM_FILE dbf, datum key, datum content, int flags)
return -1;
}
- rc = _gdbm_full_write (dbf, key.dptr, key.dsize);
+ rc = GDBM_DEBUG_OVERRIDE ("gdbm_store:write-1-failure",
+ _gdbm_full_write (dbf, key.dptr, key.dsize));
if (rc)
{
gdbm_set_errno (dbf, rc, TRUE);
@@ -160,7 +162,9 @@ gdbm_store (GDBM_FILE dbf, datum key, datum content, int flags)
return -1;
}
- rc = _gdbm_full_write (dbf, content.dptr, content.dsize);
+ rc = GDBM_DEBUG_OVERRIDE ("gdbm_store:write-2-failure",
+ _gdbm_full_write (dbf,
+ content.dptr, content.dsize));
if (rc)
{
gdbm_set_errno (dbf, rc, TRUE);

Return to:

Send suggestions and report system problems to the System administrator.