GDBM manual (split by section):   Section:   Chapter:FastBack: Reorganization   Up: Top   FastForward: Flat files   Contents: Table of ContentsIndex: Index

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 gdbm_open.

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_close function automatically calls the equivalent of gdbm_sync so no call is needed if the database is to be closed immediately after the set of changes have been made.

Gdbm_sync returns 0 on success. On error, it sets gdbm_errno and system errno variables to the codes describing the error and returns -1.

GDBM manual (split by section):   Section:   Chapter:FastBack: Reorganization   Up: Top   FastForward: Flat files   Contents: Table of ContentsIndex: Index