|Official GNU Software|
12 Database Synchronization
Unless your database was opened with the ‘GDBM_SYNC’ flag,
gdbm does not wait for writes to be flushed to the disk before
continuing. This allows for faster writing of databases at the risk
of having a corrupted database if the application terminates in an
abnormal fashion. The following function allows the programmer to
make sure the disk version of the database has been completely updated
with all changes to the current time.
- gdbm interface: int gdbm_sync (GDBM_FILE dbf)
Synchronizes the changes in dbf with its disk file. The parameter is a pointer returned by
This function would usually be called after a complete set of changes have been made to the database and before some long waiting time. The
gdbm_closefunction automatically calls the equivalent of
gdbm_syncso no call is needed if the database is to be closed immediately after the set of changes have been made.
Gdbm_syncreturns 0 on success. On error, it sets
errnovariables to the codes describing the error and returns -1.