,I'Berkeley DB: memp_unlink[P

memp_unlink





#include <db.h>

int2memp_unlink(const char *dir, int force, DB_ENV *);





Description



TThe memp_unlink function destroys the memory pool identified by the directoryAdir, removing all files used to implement the memory pool.*(The directory dir is not removed.)

¥If there are processes that have called memp_open without calling memp_closeR(i.e., there are processes currently using the memory pool), memp_unlink will failOwithout further action, unless the force flag is set, in which case memp_unlinkXwill attempt to remove the memory pool files regardless of any processes still using it.

FThe result of attempting to forcibly destroy the region when a process#has the region open is unspecified.GProcesses using a shared memory region maintain an open file descriptorfor it.2On UNIX systems, the region removal should succeedDand processes that have already joined the region should continue to!run in the region without change,Phowever processes attempting to join the memory pool will either fail or attemptto create a new region.FOn other systems (e.g., Windows/NT), where the unlink(2) systemKcall will fail if any process has an open file descriptor for the file, theregion removal will fail.

HIn the case of catastrophic or system failure, database recovery must benperformed (see db_recover), or the DB_RECOVER and DB_RECOVER_FATALSflags to db_appinit must be specified.GAlternatively, if recovery is not required because no database state isPmaintained across failures, it is possible to clean up a memory pool by removingrall of the files in the directory specified to the memp_open function,;as no memory pool files are created in any other directory.ENote, however, that this has the potential to remove files created byBthe other Berkeley DB subsystems in the same database environment.

The memp_unlinkHfunction returns the value of errno on failure, and 0 on success.



Errors

TIf a fatal error occurs in Berkeley DB, the memp_unlink function may fail and returnFDB_RUNRECOVERY, at which point all subsequent database calls will alsoreturn DB_RUNRECOVERY.

The memp_unlink)function may fail and return errnoKfor any of the errors specified for the following Berkeley DB and C library functions: abort(3), close(3),8db_version, fcntl(3), fflush(3), fprintf(3),free(3), fstat(3), fsync(3), getenv(3), getpid(3), getuid(3), isdigit(3), lseek(3), malloc(3), memcpy(3), memset(3),mmap(3), munmap(3),open(3),pstat_getdynamic(3),read(3), shmat(3), shmctl(3), shmdt(3),sigfillset(3),sigprocmask(3),stat(3), strerror(3), strlen(3), sysconf(3), unlink(3), vfprintf(3), vsnprintf(3),and write(3).

In addition, the memp_unlink)function may fail and return errnofor the following conditions:

S

EBUSY
The shared memory region was in use and the force flag was not set.




See Also

8memp_close,=memp_fclose,9memp_fget,;memp_fopen,9memp_fput,9memp_fset,;memp_fsync,6memp_open,Amemp_register,6memp_stat,6memp_stat,6memp_sync,;memp_trickleand memp_unlink.
ÿÿ