diff options
author | jbj <devnull@localhost> | 2002-09-20 13:49:09 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2002-09-20 13:49:09 +0000 |
commit | e07524eedbdf6fde6886c2258779582271187269 (patch) | |
tree | 0b46c2759e1b82d0404b5109f407ec446de8e6d6 | |
parent | 728dd6394f7feda59405bd5255741b0e38d05d6d (diff) | |
download | rpm-e07524eedbdf6fde6886c2258779582271187269.tar.gz rpm-e07524eedbdf6fde6886c2258779582271187269.tar.bz2 rpm-e07524eedbdf6fde6886c2258779582271187269.zip |
Orphans.
CVS patchset: 5725
CVS date: 2002/09/20 13:49:09
-rw-r--r-- | db/include/db_cxx.in | 726 | ||||
-rw-r--r-- | db/include/log.h | 234 | ||||
-rw-r--r-- | db/include/rep.h | 154 | ||||
-rw-r--r-- | db/include_auto/rep_ext.h | 26 | ||||
-rw-r--r-- | db/include_auto/rep_ext.in | 42 | ||||
-rw-r--r-- | db/log/log_rec.c | 696 | ||||
-rw-r--r-- | db/os_vxworks/os_vx_finit.c | 31 |
7 files changed, 0 insertions, 1909 deletions
diff --git a/db/include/db_cxx.in b/db/include/db_cxx.in deleted file mode 100644 index 95c0bc03c..000000000 --- a/db/include/db_cxx.in +++ /dev/null @@ -1,726 +0,0 @@ -/*- - * See the file LICENSE for redistribution information. - * - * Copyright (c) 1997-2001 - * Sleepycat Software. All rights reserved. - * - * Id: db_cxx.in,v 11.87 2001/11/09 21:31:35 bostic Exp - */ - -#ifndef _DB_CXX_H_ -#define _DB_CXX_H_ -// -// C++ assumptions: -// -// To ensure portability to many platforms, both new and old, we make -// few assumptions about the C++ compiler and library. For example, -// we do not expect STL, templates or namespaces to be available. The -// "newest" C++ feature used is exceptions, which are used liberally -// to transmit error information. Even the use of exceptions can be -// disabled at runtime, to do so, use the DB_CXX_NO_EXCEPTIONS flags -// with the DbEnv or Db constructor. -// -// C++ naming conventions: -// -// - All top level class names start with Db. -// - All class members start with lower case letter. -// - All private data members are suffixed with underscore. -// - Use underscores to divide names into multiple words. -// - Simple data accessors are named with get_ or set_ prefix. -// - All method names are taken from names of functions in the C -// layer of db (usually by dropping a prefix like "db_"). -// These methods have the same argument types and order, -// other than dropping the explicit arg that acts as "this". -// -// As a rule, each DbFoo object has exactly one underlying DB_FOO struct -// (defined in db.h) associated with it. In some cases, we inherit directly -// from the DB_FOO structure to make this relationship explicit. Often, -// the underlying C layer allocates and deallocates these structures, so -// there is no easy way to add any data to the DbFoo class. When you see -// a comment about whether data is permitted to be added, this is what -// is going on. Of course, if we need to add data to such C++ classes -// in the future, we will arrange to have an indirect pointer to the -// DB_FOO struct (as some of the classes already have). -// - -//////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////// -// -// Forward declarations -// - -#include <stdarg.h> - -@cxx_have_stdheaders@ -#ifdef HAVE_CXX_STDHEADERS -#include <iostream> -#define OSTREAMCLASS std::ostream -#else -#include <iostream.h> -#define OSTREAMCLASS ostream -#endif - -#include "db.h" -#include "cxx_common.h" -#include "cxx_except.h" - -class Db; // forward -class Dbc; // forward -class DbEnv; // forward -class DbInfo; // forward -class DbLock; // forward -class DbLogc; // forward -class DbLsn; // forward -class DbMpoolFile; // forward -class Dbt; // forward -class DbTxn; // forward - -// These classes are not defined here and should be invisible -// to the user, but some compilers require forward references. -// There is one for each use of the DEFINE_DB_CLASS macro. - -class DbImp; -class DbEnvImp; -class DbMpoolFileImp; -class DbTxnImp; - -// DEFINE_DB_CLASS defines an imp_ data member and imp() accessor. -// The underlying type is a pointer to an opaque *Imp class, that -// gets converted to the correct implementation class by the implementation. -// -// Since these defines use "private/public" labels, and leave the access -// being "private", we always use these by convention before any data -// members in the private section of a class. Keeping them in the -// private section also emphasizes that they are off limits to user code. -// -#define DEFINE_DB_CLASS(name) \ - public: class name##Imp* imp() { return (imp_); } \ - public: const class name##Imp* constimp() const { return (imp_); } \ - private: class name##Imp* imp_ - -//////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////// -// -// Turn off inappropriate compiler warnings -// - -#ifdef _MSC_VER - -// These are level 4 warnings that are explicitly disabled. -// With Visual C++, by default you do not see above level 3 unless -// you use /W4. But we like to compile with the highest level -// warnings to catch other errors. -// -// 4201: nameless struct/union -// triggered by standard include file <winnt.h> -// -// 4514: unreferenced inline function has been removed -// certain include files in MSVC define methods that are not called -// -#pragma warning(disable: 4201 4514) - -#endif - -// Some interfaces can be customized by allowing users to define -// callback functions. For performance and logistical reasons, some -// callback functions must be declared in extern "C" blocks. For others, -// we allow you to declare the callbacks in C++ or C (or an extern "C" -// block) as you wish. See the set methods for the callbacks for -// the choices. -// -extern "C" { - typedef void * (*db_malloc_fcn_type) - (size_t); - typedef void * (*db_realloc_fcn_type) - (void *, size_t); - typedef void (*db_free_fcn_type) - (void *); - typedef int (*bt_compare_fcn_type) /*C++ version available*/ - (DB *, const DBT *, const DBT *); - typedef size_t (*bt_prefix_fcn_type) /*C++ version available*/ - (DB *, const DBT *, const DBT *); - typedef int (*dup_compare_fcn_type) /*C++ version available*/ - (DB *, const DBT *, const DBT *); - typedef u_int32_t (*h_hash_fcn_type) /*C++ version available*/ - (DB *, const void *, u_int32_t); - typedef int (*pgin_fcn_type) - (DB_ENV *dbenv, db_pgno_t pgno, void *pgaddr, DBT *pgcookie); - typedef int (*pgout_fcn_type) - (DB_ENV *dbenv, db_pgno_t pgno, void *pgaddr, DBT *pgcookie); -}; - -//////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////// -// -// Lock classes -// - -class _exported DbLock -{ - friend class DbEnv; - -public: - DbLock(); - - int put(DbEnv *env); - - DbLock(const DbLock &); - DbLock &operator = (const DbLock &); - -protected: - // We can add data to this class if needed - // since its contained class is not allocated by db. - // (see comment at top) - - DbLock(DB_LOCK); - DB_LOCK lock_; -}; - -//////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////// -// -// Log classes -// - -class _exported DbLsn : protected DB_LSN -{ - friend class DbEnv; // friendship needed to cast to base class - friend class DbLogc; // friendship needed to cast to base class -}; - -//////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////// -// -// Memory pool classes -// - -class _exported DbMpoolFile -{ - friend class DbEnv; - -public: - int close(u_int32_t flags); - int get(db_pgno_t *pgnoaddr, u_int32_t flags, void *pagep); - void last_pgno(db_pgno_t *pgnoaddr); - int open(const char *file, u_int32_t flags, int mode, size_t pagesize); - int put(void *pgaddr, u_int32_t flags); - void refcnt(db_pgno_t *pgnoaddr); - int set(void *pgaddr, u_int32_t flags); - int set_clear_len(u_int32_t len); - int set_fileid(u_int8_t *fileid); - int set_ftype(int ftype); - int set_lsn_offset(int32_t offset); - int set_pgcookie(DBT *dbt); - void set_unlink(int); - int sync(); - -private: - // We can add data to this class if needed - // since it is implemented via a pointer. - // (see comment at top) - - // Note: use DbEnv::memp_fcreate() to get pointers to a DbMpoolFile, - // and call DbMpoolFile::close() rather than delete to release them. - // - DbMpoolFile(); - - // Shut g++ up. -protected: - ~DbMpoolFile(); - -private: - // no copying - DbMpoolFile(const DbMpoolFile &); - void operator = (const DbMpoolFile &); - - DEFINE_DB_CLASS(DbMpoolFile); -}; - -//////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////// -// -// Transaction classes -// - -class _exported DbTxn -{ - friend class DbEnv; - -public: - int abort(); - int commit(u_int32_t flags); - u_int32_t id(); - int prepare(u_int8_t *gid); - int set_timeout(db_timeout_t timeout, u_int32_t flags); - -private: - // We can add data to this class if needed - // since it is implemented via a pointer. - // (see comment at top) - - // Note: use DbEnv::txn_begin() to get pointers to a DbTxn, - // and call DbTxn::abort() or DbTxn::commit rather than - // delete to release them. - // - DbTxn(); - ~DbTxn(); - - // no copying - DbTxn(const DbTxn &); - void operator = (const DbTxn &); - - DEFINE_DB_CLASS(DbTxn); -}; - -// -// Berkeley DB environment class. Provides functions for opening databases. -// User of this library can use this class as a starting point for -// developing a DB application - derive their application class from -// this one, add application control logic. -// -// Note that if you use the default constructor, you must explicitly -// call appinit() before any other db activity (e.g. opening files) -// -class _exported DbEnv -{ - friend class Db; - friend class DbLock; - friend class DbMpoolFile; - -public: - - ~DbEnv(); - - // After using this constructor, you can set any needed - // parameters for the environment using the set_* methods. - // Then call open() to finish initializing the environment - // and attaching it to underlying files. - // - DbEnv(u_int32_t flags); - - // These methods match those in the C interface. - // - int close(u_int32_t); - void err(int, const char *, ...); - void errx(const char *, ...); - void *get_app_private() const; - int open(const char *, u_int32_t, int); - int remove(const char *, u_int32_t); - int set_alloc(db_malloc_fcn_type, db_realloc_fcn_type, - db_free_fcn_type); - void set_app_private(void *); - int set_cachesize(u_int32_t, u_int32_t, int); - int set_data_dir(const char *); - void set_errcall(void (*)(const char *, char *)); - void set_errfile(FILE *); - void set_errpfx(const char *); - int set_flags(u_int32_t, int); - int set_feedback(void (*)(DbEnv *, int, int)); - int set_recovery_init(int (*)(DbEnv *)); - int set_lg_bsize(u_int32_t); - int set_lg_dir(const char *); - int set_lg_max(u_int32_t); - int set_lg_regionmax(u_int32_t); - int set_lk_conflicts(u_int8_t *, int); - int set_lk_detect(u_int32_t); - int set_lk_max(u_int32_t); - int set_lk_max_lockers(u_int32_t); - int set_lk_max_locks(u_int32_t); - int set_lk_max_objects(u_int32_t); - int set_mp_mmapsize(size_t); - int set_paniccall(void (*)(DbEnv *, int)); - int set_rpc_server(void *, char *, long, long, u_int32_t); - int set_shm_key(long); - int set_timeout(db_timeout_t timeout, u_int32_t flags); - int set_tmp_dir(const char *); - int set_tas_spins(u_int32_t); - int set_tx_max(u_int32_t); - int set_tx_recover(int (*)(DbEnv *, Dbt *, DbLsn *, db_recops)); - int set_tx_timestamp(time_t *); - int set_verbose(u_int32_t which, int onoff); - - // Version information. A static method so it can be obtained anytime. - // - static char *version(int *major, int *minor, int *patch); - - // Convert DB errors to strings - static char *strerror(int); - - // If an error is detected and the error call function - // or stream is set, a message is dispatched or printed. - // If a prefix is set, each message is prefixed. - // - // You can use set_errcall() or set_errfile() above to control - // error functionality. Alternatively, you can call - // set_error_stream() to force all errors to a C++ stream. - // It is unwise to mix these approaches. - // - void set_error_stream(OSTREAMCLASS *); - - // used internally - static void runtime_error(const char *caller, int err, - int error_policy); - static void runtime_error_dbt(const char *caller, Dbt *dbt, - int error_policy); - - // Lock functions - // - int lock_detect(u_int32_t flags, u_int32_t atype, int *aborted); - int lock_get(u_int32_t locker, u_int32_t flags, const Dbt *obj, - db_lockmode_t lock_mode, DbLock *lock); - int lock_id(u_int32_t *idp); - int lock_id_free(u_int32_t id); - int lock_stat(DB_LOCK_STAT **statp, u_int32_t flags); - int lock_vec(u_int32_t locker, u_int32_t flags, DB_LOCKREQ list[], - int nlist, DB_LOCKREQ **elistp); - - // Log functions - // - int log_archive(char **list[], u_int32_t flags); - static int log_compare(const DbLsn *lsn0, const DbLsn *lsn1); - int log_cursor(DbLogc **cursorp, u_int32_t flags); - int log_file(DbLsn *lsn, char *namep, size_t len); - int log_flush(const DbLsn *lsn); - int log_put(DbLsn *lsn, const Dbt *data, u_int32_t flags); - - int log_register(Db *dbp, const char *name); - int log_stat(DB_LOG_STAT **spp, u_int32_t flags); - int log_unregister(Db *dbp); - - // Mpool functions - // - int memp_fcreate(DbMpoolFile **dbmfp, u_int32_t flags); - int memp_register(int ftype, - pgin_fcn_type pgin_fcn, - pgout_fcn_type pgout_fcn); - int memp_stat(DB_MPOOL_STAT - **gsp, DB_MPOOL_FSTAT ***fsp, u_int32_t flags); - int memp_sync(DbLsn *lsn); - int memp_trickle(int pct, int *nwrotep); - - // Transaction functions - // - int txn_begin(DbTxn *pid, DbTxn **tid, u_int32_t flags); - int txn_checkpoint(u_int32_t kbyte, u_int32_t min, u_int32_t flags); - int txn_recover(DB_PREPLIST *preplist, long count, - long *retp, u_int32_t flags); - int txn_stat(DB_TXN_STAT **statp, u_int32_t flags); - - // Replication functions - // - int rep_elect(int, int, u_int32_t, int *); - int rep_process_message(Dbt *, Dbt *, int *); - int rep_start(Dbt *, u_int32_t); - int set_rep_transport(u_int32_t, - int (*)(DbEnv *, const Dbt *, const Dbt *, int, u_int32_t)); - - // Conversion functions - // - DB_ENV *get_DB_ENV() - { - return (DB_ENV *)imp(); - } - - const DB_ENV *get_const_DB_ENV() const - { - return (const DB_ENV *)constimp(); - } - - static DbEnv* get_DbEnv(DB_ENV *dbenv) - { - return (DbEnv *)dbenv->cj_internal; - } - - static const DbEnv* get_const_DbEnv(const DB_ENV *dbenv) - { - return (const DbEnv *)dbenv->cj_internal; - } - - // These are public only because they need to be called - // via C functions. They should never be called by users - // of this class. - // - static void _stream_error_function(const char *, char *); - static int _tx_recover_intercept(DB_ENV *env, DBT *dbt, DB_LSN *lsn, - db_recops op); - static void _paniccall_intercept(DB_ENV *env, int errval); - static int _recovery_init_intercept(DB_ENV *env); - static void _feedback_intercept(DB_ENV *env, int opcode, int pct); - static int _rep_send_intercept(DB_ENV *env, - const DBT *cntrl, const DBT *data, - int id, u_int32_t flags); - static void _destroy_check(const char *str, int isDbEnv); - -private: - void cleanup(); - int initialize(DB_ENV *env); - int error_policy(); - - // Used internally - DbEnv(DB_ENV *, u_int32_t flags); - - // no copying - DbEnv(const DbEnv &); - void operator = (const DbEnv &); - - DEFINE_DB_CLASS(DbEnv); - - // instance data - int construct_error_; - u_int32_t construct_flags_; - int (*tx_recover_callback_)(DbEnv *, Dbt *, DbLsn *, db_recops); - int (*recovery_init_callback_)(DbEnv *); - void (*paniccall_callback_)(DbEnv *, int); - void (*feedback_callback_)(DbEnv *, int, int); - int (*pgin_callback_)(DbEnv *dbenv, db_pgno_t pgno, - void *pgaddr, Dbt *pgcookie); - int (*pgout_callback_)(DbEnv *dbenv, db_pgno_t pgno, - void *pgaddr, Dbt *pgcookie); - int (*rep_send_callback_)(DbEnv *, - const Dbt *, const Dbt *, int, u_int32_t); - - // class data - static OSTREAMCLASS *error_stream_; -}; - -//////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////// -// -// Table access classes -// - -// -// Represents a database table = a set of keys with associated values. -// -class _exported Db -{ - friend class DbEnv; - -public: - Db(DbEnv*, u_int32_t); // create a Db object, then call open() - ~Db(); // does *not* call close. - - // These methods exactly match those in the C interface. - // - int associate(Db *secondary, int (*callback)(Db *, const Dbt *, - const Dbt *, Dbt *), u_int32_t flags); - int close(u_int32_t flags); - int cursor(DbTxn *txnid, Dbc **cursorp, u_int32_t flags); - int del(DbTxn *txnid, Dbt *key, u_int32_t flags); - void err(int, const char *, ...); - void errx(const char *, ...); - int fd(int *fdp); - int get(DbTxn *txnid, Dbt *key, Dbt *data, u_int32_t flags); - void *get_app_private() const; - int get_byteswapped(int *); - int get_type(DBTYPE *); - int join(Dbc **curslist, Dbc **dbcp, u_int32_t flags); - int key_range(DbTxn *, Dbt *, DB_KEY_RANGE *, u_int32_t); - int open(const char *, const char *subname, DBTYPE, u_int32_t, int); - int pget(DbTxn *txnid, Dbt *key, Dbt *pkey, Dbt *data, - u_int32_t flags); - int put(DbTxn *, Dbt *, Dbt *, u_int32_t); - int remove(const char *, const char *, u_int32_t); - int rename(const char *, const char *, const char *, u_int32_t); - int set_alloc(db_malloc_fcn_type, db_realloc_fcn_type, - db_free_fcn_type); - void set_app_private(void *); - int set_append_recno(int (*)(Db *, Dbt *, db_recno_t)); - int set_bt_compare(bt_compare_fcn_type); /*deprecated*/ - int set_bt_compare(int (*)(Db *, const Dbt *, const Dbt *)); - int set_bt_maxkey(u_int32_t); - int set_bt_minkey(u_int32_t); - int set_bt_prefix(bt_prefix_fcn_type); /*deprecated*/ - int set_bt_prefix(size_t (*)(Db *, const Dbt *, const Dbt *)); - int set_cachesize(u_int32_t, u_int32_t, int); - int set_dup_compare(dup_compare_fcn_type); /*deprecated*/ - int set_dup_compare(int (*)(Db *, const Dbt *, const Dbt *)); - void set_errcall(void (*)(const char *, char *)); - void set_errfile(FILE *); - void set_errpfx(const char *); - int set_feedback(void (*)(Db *, int, int)); - int set_flags(u_int32_t); - int set_h_ffactor(u_int32_t); - int set_h_hash(h_hash_fcn_type); /*deprecated*/ - int set_h_hash(u_int32_t (*)(Db *, const void *, u_int32_t)); - int set_h_nelem(u_int32_t); - int set_lorder(int); - int set_pagesize(u_int32_t); - int set_paniccall(void (*)(DbEnv *, int)); - int set_re_delim(int); - int set_re_len(u_int32_t); - int set_re_pad(int); - int set_re_source(char *); - int set_q_extentsize(u_int32_t); - int stat(void *sp, u_int32_t flags); - int sync(u_int32_t flags); - int truncate(DbTxn *, u_int32_t *, u_int32_t); - int upgrade(const char *name, u_int32_t flags); - int verify(const char *, const char *, OSTREAMCLASS *, u_int32_t); - - // These additional methods are not in the C interface, and - // are only available for C++. - // - void set_error_stream(OSTREAMCLASS *); - - DB *get_DB() - { - return (DB *)imp(); - } - - const DB *get_const_DB() const - { - return (const DB *)constimp(); - } - - static Db* get_Db(DB *db) - { - return (Db *)db->cj_internal; - } - - static const Db* get_const_Db(const DB *db) - { - return (const Db *)db->cj_internal; - } - - // These are public only because they need to be called - // via C callback functions. They should never be used by - // external users of this class. - // - void (*feedback_callback_)(Db *, int, int); - int (*append_recno_callback_)(Db *, Dbt *, db_recno_t); - int (*bt_compare_callback_)(Db *, const Dbt *, const Dbt *); - size_t (*bt_prefix_callback_)(Db *, const Dbt *, const Dbt *); - int (*dup_compare_callback_)(Db *, const Dbt *, const Dbt *); - u_int32_t (*h_hash_callback_)(Db *, const void *, u_int32_t); - int (*associate_callback_)(Db *, const Dbt *, const Dbt *, Dbt *); -private: - - // no copying - Db(const Db &); - Db &operator = (const Db &); - - DEFINE_DB_CLASS(Db); - - void cleanup(); - int initialize(); - int error_policy(); - - // instance data - DbEnv *env_; - int construct_error_; - u_int32_t flags_; - u_int32_t construct_flags_; -}; - -// -// A chunk of data, maybe a key or value. -// -class _exported Dbt : private DBT -{ - friend class Dbc; - friend class Db; - friend class DbEnv; - friend class DbLogc; - -public: - - // key/data - void *get_data() const { return data; } - void set_data(void *value) { data = value; } - - // key/data length - u_int32_t get_size() const { return size; } - void set_size(u_int32_t value) { size = value; } - - // RO: length of user buffer. - u_int32_t get_ulen() const { return ulen; } - void set_ulen(u_int32_t value) { ulen = value; } - - // RO: get/put record length. - u_int32_t get_dlen() const { return dlen; } - void set_dlen(u_int32_t value) { dlen = value; } - - // RO: get/put record offset. - u_int32_t get_doff() const { return doff; } - void set_doff(u_int32_t value) { doff = value; } - - // flags - u_int32_t get_flags() const { return flags; } - void set_flags(u_int32_t value) { flags = value; } - - // Conversion functions - DBT *get_DBT() { return (DBT *)this; } - const DBT *get_const_DBT() const { return (const DBT *)this; } - - static Dbt* get_Dbt(DBT *dbt) { return (Dbt *)dbt; } - static const Dbt* get_const_Dbt(const DBT *dbt) - { return (const Dbt *)dbt; } - - Dbt(void *data, size_t size); - Dbt(); - ~Dbt(); - Dbt(const Dbt &); - Dbt &operator = (const Dbt &); - -private: - // Note: no extra data appears in this class (other than - // inherited from DBT) since we need DBT and Dbt objects - // to have interchangable pointers. - // - // When subclassing this class, remember that callback - // methods like bt_compare, bt_prefix, dup_compare may - // internally manufacture DBT objects (which later are - // cast to Dbt), so such callbacks might receive objects - // not of your subclassed type. -}; - -class _exported Dbc : protected DBC -{ - friend class Db; - -public: - int close(); - int count(db_recno_t *countp, u_int32_t flags); - int del(u_int32_t flags); - int dup(Dbc** cursorp, u_int32_t flags); - int get(Dbt* key, Dbt *data, u_int32_t flags); - int pget(Dbt* key, Dbt* pkey, Dbt *data, u_int32_t flags); - int put(Dbt* key, Dbt *data, u_int32_t flags); - -private: - // No data is permitted in this class (see comment at top) - - // Note: use Db::cursor() to get pointers to a Dbc, - // and call Dbc::close() rather than delete to release them. - // - Dbc(); - ~Dbc(); - - // no copying - Dbc(const Dbc &); - Dbc &operator = (const Dbc &); -}; - -class _exported DbLogc : protected DB_LOGC -{ - friend class DbEnv; - -public: - int close(u_int32_t _flags); - int get(DbLsn *lsn, Dbt *data, u_int32_t _flags); - -private: - // No data is permitted in this class (see comment at top) - - // Note: use Db::cursor() to get pointers to a Dbc, - // and call Dbc::close() rather than delete to release them. - // - DbLogc(); - ~DbLogc(); - - // no copying - DbLogc(const Dbc &); - DbLogc &operator = (const Dbc &); -}; -#endif /* !_DB_CXX_H_ */ diff --git a/db/include/log.h b/db/include/log.h deleted file mode 100644 index 45c119857..000000000 --- a/db/include/log.h +++ /dev/null @@ -1,234 +0,0 @@ -/*- - * See the file LICENSE for redistribution information. - * - * Copyright (c) 1996-2001 - * Sleepycat Software. All rights reserved. - * - * Id: log.h,v 11.38 2001/11/16 10:57:49 krinsky Exp - */ - -#ifndef _LOG_H_ -#define _LOG_H_ - -struct __db_log; typedef struct __db_log DB_LOG; -struct __fname; typedef struct __fname FNAME; -struct __hdr; typedef struct __hdr HDR; -struct __log; typedef struct __log LOG; -struct __log_persist; typedef struct __log_persist LOGP; - -#define LFPREFIX "log." /* Log file name prefix. */ -#define LFNAME "log.%010d" /* Log file name template. */ -#define LFNAME_V1 "log.%05d" /* Log file name template, rev 1. */ - -#define LG_MAX_DEFAULT (10 * MEGABYTE) /* 10 MB. */ -#define LG_BSIZE_DEFAULT (32 * 1024) /* 32 KB. */ -#define LG_BASE_REGION_SIZE (60 * 1024) /* 60 KB. */ - -/* - * The per-process table that maps log file-id's to DB structures. - */ -typedef struct __db_entry { - TAILQ_HEAD(dblist, __db) dblist;/* Associated DB structures. */ - u_int32_t refcount; /* Reference counted. */ - u_int32_t count; /* Number of ops on a deleted db. */ - int deleted; /* File was not found during open. */ -} DB_ENTRY; - -/* - * DB_LOG - * Per-process log structure. - */ -struct __db_log { -/* - * These fields need to be protected for multi-threaded support. - * - * !!! - * As this structure is allocated in per-process memory, the mutex may need - * to be stored elsewhere on architectures unable to support mutexes in heap - * memory, e.g., HP/UX 9. - */ - DB_MUTEX *mutexp; /* Mutex for thread protection. */ - - DB_ENTRY *dbentry; /* Recovery file-id mapping. */ -#define DB_GROW_SIZE 64 - int32_t dbentry_cnt; /* Entries. Grows by DB_GROW_SIZE. */ - -/* - * These fields are always accessed while the region lock is held, so they do - * not have to be protected by the thread lock as well, OR, they are only used - * when threads are not being used, i.e. most cursor operations are disallowed - * on threaded logs. - */ - u_int32_t lfname; /* Log file "name". */ - DB_FH lfh; /* Log file handle. */ - - u_int8_t *bufp; /* Region buffer. */ - -/* These fields are not protected. */ - DB_ENV *dbenv; /* Reference to error information. */ - REGINFO reginfo; /* Region information. */ - -#define DBLOG_RECOVER 0x01 /* We are in recovery. */ -#define DBLOG_FORCE_OPEN 0x02 /* Force the DB open even if it appears - * to be deleted. - */ - u_int32_t flags; -}; - -/* - * HDR -- - * Log record header. - */ -struct __hdr { - u_int32_t prev; /* Previous offset. */ - u_int32_t cksum; /* Current checksum. */ - u_int32_t len; /* Current length. */ -}; - -struct __log_persist { - u_int32_t magic; /* DB_LOGMAGIC */ - u_int32_t version; /* DB_LOGVERSION */ - - u_int32_t lg_max; /* Maximum file size. */ - int mode; /* Log file mode. */ -}; - -/* - * LOG -- - * Shared log region. One of these is allocated in shared memory, - * and describes the log. - */ -struct __log { - LOGP persist; /* Persistent information. */ - - SH_TAILQ_HEAD(__fq) fq; /* List of file names. */ - - /* - * The lsn LSN is the file offset that we're about to write and which - * we will return to the user. - */ - DB_LSN lsn; /* LSN at current file offset. */ - - /* - * The f_lsn LSN is the LSN (returned to the user) that "owns" the - * first byte of the buffer. If the record associated with the LSN - * spans buffers, it may not reflect the physical file location of - * the first byte of the buffer. - */ - DB_LSN f_lsn; /* LSN of first byte in the buffer. */ - size_t b_off; /* Current offset in the buffer. */ - u_int32_t w_off; /* Current write offset in the file. */ - u_int32_t len; /* Length of the last record. */ - - /* - * The s_lsn LSN is the last LSN that we know is on disk, not just - * written, but synced. This field only is protected by the - * flush mutex rather than by the region mutex. - */ - int in_flush; /* Log flush in progress. */ - DB_MUTEX flush; /* Mutex for flushing. */ - DB_LSN s_lsn; /* LSN of the last sync. */ - - DB_LSN chkpt_lsn; /* LSN of the last checkpoint. */ - time_t chkpt; /* Time of the last checkpoint. */ - - DB_LOG_STAT stat; /* Log statistics. */ - - /* - * The waiting_lsn is used by the replication system. It is the - * first LSN that we are holding without putting in the log, because - * we received one or more log records out of order. - */ - DB_LSN waiting_lsn; /* First log record after a gap. */ - - /* - * The ready_lsn is also used by the replication system. It is the - * next LSN we expect to receive. It's normally equal to "lsn", - * except at the beginning of a log file, at which point it's set - * to the LSN of the first record of the new file (after the - * header), rather than to 0. - */ - DB_LSN ready_lsn; - - roff_t buffer_off; /* Log buffer offset in the region. */ - u_int32_t buffer_size; /* Log buffer size. */ - - u_int32_t ncommit; /* Number of txns waiting to commit. */ - - DB_LSN t_lsn; /* LSN of first commit */ - SH_TAILQ_HEAD(__commit) commits;/* list of txns waiting to commit. */ - SH_TAILQ_HEAD(__free) free_commits;/* free list of commit structs. */ - -#define LOG_NEWFILE 0x01 - u_int32_t flags; /* Environment-wide flag values. */ - -#ifdef MUTEX_SYSTEM_RESOURCES -#define LG_MAINT_SIZE (sizeof(roff_t) * DB_MAX_HANDLES) - - roff_t maint_off; /* offset of region maintenance info */ -#endif -}; - -/* - * __db_commit structure -- - * One of these is allocated for each transaction waiting - * to commit. - */ -struct __db_commit { - DB_MUTEX mutex; /* Mutex for txn to wait on. */ - DB_LSN lsn; /* LSN of commit record. */ - SH_TAILQ_ENTRY links; /* Either on free or waiting list. */ - -#define DB_COMMIT_FLUSH 0x0001 /* Flush the log when you wake up. */ - u_int32_t flags; -}; - -/* - * FNAME -- - * File name and id. - */ -struct __fname { - SH_TAILQ_ENTRY q; /* File name queue. */ - - u_int16_t ref; /* Reference count. */ - u_int16_t locked; /* Table is locked. */ - - int32_t id; /* Logging file id. */ - DBTYPE s_type; /* Saved DB type. */ - - roff_t name_off; /* Name offset. */ - db_pgno_t meta_pgno; /* Page number of the meta page. */ - u_int8_t ufid[DB_FILE_ID_LEN]; /* Unique file id. */ -}; - -/* File open/close register log record opcodes. */ -#define LOG_CHECKPOINT 1 /* Checkpoint: file name/id dump. */ -#define LOG_CLOSE 2 /* File close. */ -#define LOG_OPEN 3 /* File open. */ -#define LOG_RCLOSE 4 /* File close after recovery. */ - -#define CHECK_LSN(redo, cmp, lsn, prev) \ - DB_ASSERT(!DB_REDO(redo) || (cmp) >= 0); \ - if (DB_REDO(redo) && (cmp) < 0) { \ - __db_err(dbenv, \ - "Log sequence error: page LSN %lu:%lu; previous LSN %lu %lu", \ - (u_long)(lsn)->file, (u_long)(lsn)->offset, \ - (u_long)(prev)->file, (u_long)(prev)->offset); \ - goto out; \ - } - -/* - * Status codes indicating the validity of a log file examined by - * __log_valid(). - */ -typedef enum { - DB_LV_INCOMPLETE, - DB_LV_NONEXISTENT, - DB_LV_NORMAL, - DB_LV_OLD_READABLE, - DB_LV_OLD_UNREADABLE -} logfile_validity; - -#include "log_auto.h" -#include "log_ext.h" -#endif /* _LOG_H_ */ diff --git a/db/include/rep.h b/db/include/rep.h deleted file mode 100644 index bcf8f26c3..000000000 --- a/db/include/rep.h +++ /dev/null @@ -1,154 +0,0 @@ -/*- - * See the file LICENSE for redistribution information. - * - * Copyright (c) 2001 - * Sleepycat Software. All rights reserved. - */ - -#ifndef _REP_H_ -#define _REP_H_ - -#define REP_ALIVE 1 /* I am alive message. */ -#define REP_ALIVE_REQ 2 /* Request for alive messages. */ -#define REP_ALL_REQ 3 /* Request all log records greater than LSN. */ -#define REP_ELECT 4 /* Indicates that all listeners should */ - /* begin master election */ -#define REP_FILE 6 /* Page of a database file. */ -#define REP_FILE_REQ 7 /* Request for a database file. */ -#define REP_LOG 8 /* Log record. */ -#define REP_LOG_REQ 9 /* Request for a log record. */ -#define REP_MASTER_REQ 10 /* Who is the master */ -#define REP_NEWCLIENT 11 /* Announces the presence of a new client. */ -#define REP_NEWFILE 12 /* Announce a log file change. */ -#define REP_NEWMASTER 13 /* Announces who the master is. */ -#define REP_NEWSITE 14 /* Announces that a site has heard from a new - * site; like NEWCLIENT, but indirect. A - * NEWCLIENT message comes directly from the new - * client while a NEWSITE comes indirectly from - * someone who heard about a NEWSITE. - */ -#define REP_PAGE 15 /* Database page. */ -#define REP_PAGE_REQ 16 /* Request for a database page. */ -#define REP_PLIST 17 /* Database page list. */ -#define REP_PLIST_REQ 18 /* Request for a page list. */ -#define REP_VERIFY 19 /* A log record for verification. */ -#define REP_VERIFY_FAIL 20 /* The client is outdated. */ -#define REP_VERIFY_REQ 21 /* Request for a log record to verify. */ -#define REP_VOTE1 22 /* Send out your information for an election. */ -#define REP_VOTE2 23 /* Send a "you are master" vote. */ - -/* Used to consistently designate which messages ought to be received where. */ -#define MASTER_ONLY(dbenv) \ - if (!F_ISSET(dbenv, DB_ENV_REP_MASTER)) return (EINVAL) - -#define CLIENT_ONLY(dbenv) \ - if (!F_ISSET(dbenv, DB_ENV_REP_CLIENT)) return (EINVAL) - -#define ANYSITE(dbenv) - -/* Shared replication structure. */ - -typedef struct __rep { - DB_MUTEX mutex; /* Region lock. */ - u_int32_t tally_off; /* Offset of the tally region. */ - int eid; /* Environment id. */ - int master_id; /* ID of the master site. */ - u_int32_t gen; /* Replication generation number */ - int asites; /* Space allocated for sites. */ - int nsites; /* Number of sites in group. */ - int priority; /* My priority in an election. */ - - /* Vote tallying information. */ - int sites; /* Sites heard from. */ - int winner; /* Current winner. */ - int w_priority; /* Winner priority. */ - u_int32_t w_gen; /* Winner generation. */ - DB_LSN w_lsn; /* Winner LSN. */ - int votes; /* Number of votes for this site. */ - -#define REP_F_EPHASE1 0x01 /* In phase 1 of election. */ -#define REP_F_EPHASE2 0x02 /* In phase 2 of election. */ -#define REP_F_LOGSONLY 0x04 /* Log-site only; cannot be upgraded. */ -#define REP_F_MASTER 0x08 /* Master replica. */ -#define REP_F_RECOVER 0x10 -#define REP_F_UPGRADE 0x20 /* Upgradeable replica. */ -#define REP_ISCLIENT (REP_F_UPGRADE | REP_F_LOGSONLY) - u_int32_t flags; -} REP; - -#define IN_ELECTION(R) F_ISSET((R), REP_F_EPHASE1 | REP_F_EPHASE2) -#define ELECTION_DONE(R) F_CLR((R), REP_F_EPHASE1 | REP_F_EPHASE2) - -/* - * Per-process replication structure. - */ -struct __db_rep { - DB_MUTEX *mutexp; - DB *rep_db; /* Bookkeeping database. */ - REP *region; /* In memory structure. */ - int (*rep_send) /* Send function. */ - __P((DB_ENV *, - const DBT *, const DBT *, int, u_int32_t)); -}; - -/* - * Control structure for replication communication infrastructure. - * - * Note that the version information should be at the beginning of the - * structure, so that we can rearrange the rest of it while letting the - * version checks continue to work. DB_REPVERSION should be revved any time - * the rest of the structure changes. - */ -typedef struct __rep_control { -#define DB_REPVERSION 1 - u_int32_t rep_version; /* Replication version number. */ - u_int32_t log_version; /* Log version number. */ - - DB_LSN lsn; /* Log sequence number. */ - u_int32_t rectype; /* Message type. */ - u_int32_t gen; /* Generation number. */ - u_int32_t flags; /* log_put flag value. */ -} REP_CONTROL; - -/* Election vote information. */ -typedef struct __rep_vote { - int priority; /* My site's priority. */ - int nsites; /* Number of sites I've been in - * communication with. */ -} REP_VOTE_INFO; - -/* - * This structure takes care of representing a transaction. - * It holds all the records, sorted by page number so that - * we can obtain locks and apply updates in a deadlock free - * order. - */ -typedef struct __lsn_page { - DB_LSN lsn; - u_int32_t fid; - DB_LOCK_ILOCK pgdesc; -#define LSN_PAGE_NOLOCK 0x0001 /* No lock necessary for log rec. */ - u_int32_t flags; -} LSN_PAGE; - -typedef struct __txn_recs { - int npages; - int nalloc; - LSN_PAGE *array; - u_int32_t txnid; - u_int32_t lockid; -} TXN_RECS; - -/* - * This is used by the page-prep routines to do the lock_vec call to - * apply the updates for a single transaction or a collection of - * transactions. - */ -typedef struct _linfo { - int n; - DB_LOCKREQ *reqs; - DBT *objs; -} linfo_t; - -#include "rep_ext.h" -#endif /* _REP_H_ */ diff --git a/db/include_auto/rep_ext.h b/db/include_auto/rep_ext.h deleted file mode 100644 index 440065c25..000000000 --- a/db/include_auto/rep_ext.h +++ /dev/null @@ -1,26 +0,0 @@ -/* DO NOT EDIT: automatically built by dist/s_include. */ -#ifndef _rep_ext_h_ -#define _rep_ext_h_ -#if defined(__cplusplus) -extern "C" { -#endif -int __rep_dbenv_create __P((DB_ENV *)); -int __rep_process_message __P((DB_ENV *, DBT *, DBT *, int *)); -int __rep_client_dbinit __P((DB_ENV *, int)); -int __rep_region_init __P((DB_ENV *)); -int __rep_region_destroy __P((DB_ENV *)); -int __rep_dbenv_close __P((DB_ENV *)); -int __rep_preclose __P((DB_ENV *)); -int __rep_check_alloc __P((DB_ENV *, TXN_RECS *, int)); -int __rep_send_message __P((DB_ENV *, int, u_int32_t, DB_LSN *, const DBT *, u_int32_t)); -int __rep_new_master __P((DB_ENV *, REP_CONTROL *, int)); -int __rep_lockpgno_init __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *)); -int __rep_unlockpages __P((DB_ENV *, u_int32_t)); -int __rep_lockpages __P((DB_ENV *, int (**)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), DB_LSN *, DB_LSN *, TXN_RECS *, u_int32_t)); -int __rep_is_client __P((DB_ENV *)); -int __rep_send_vote __P((DB_ENV *, DB_LSN *, int, int)); -int __rep_grow_sites __P((DB_ENV *dbenv, int nsites)); -#if defined(__cplusplus) -} -#endif -#endif /* _rep_ext_h_ */ diff --git a/db/include_auto/rep_ext.in b/db/include_auto/rep_ext.in deleted file mode 100644 index d0157753f..000000000 --- a/db/include_auto/rep_ext.in +++ /dev/null @@ -1,42 +0,0 @@ -/* DO NOT EDIT: automatically built by dist/s_include. */ -#ifndef _rep_ext_h_ -#define _rep_ext_h_ -#if defined(__cplusplus) -extern "C" { -#endif -#define __rep_dbenv_create __rep_dbenv_create@DB_VERSION_UNIQUE_NAME@ -int __rep_dbenv_create __P((DB_ENV *)); -#define __rep_process_message __rep_process_message@DB_VERSION_UNIQUE_NAME@ -int __rep_process_message __P((DB_ENV *, DBT *, DBT *, int *)); -#define __rep_client_dbinit __rep_client_dbinit@DB_VERSION_UNIQUE_NAME@ -int __rep_client_dbinit __P((DB_ENV *, int)); -#define __rep_region_init __rep_region_init@DB_VERSION_UNIQUE_NAME@ -int __rep_region_init __P((DB_ENV *)); -#define __rep_region_destroy __rep_region_destroy@DB_VERSION_UNIQUE_NAME@ -int __rep_region_destroy __P((DB_ENV *)); -#define __rep_dbenv_close __rep_dbenv_close@DB_VERSION_UNIQUE_NAME@ -int __rep_dbenv_close __P((DB_ENV *)); -#define __rep_preclose __rep_preclose@DB_VERSION_UNIQUE_NAME@ -int __rep_preclose __P((DB_ENV *)); -#define __rep_check_alloc __rep_check_alloc@DB_VERSION_UNIQUE_NAME@ -int __rep_check_alloc __P((DB_ENV *, TXN_RECS *, int)); -#define __rep_send_message __rep_send_message@DB_VERSION_UNIQUE_NAME@ -int __rep_send_message __P((DB_ENV *, int, u_int32_t, DB_LSN *, const DBT *, u_int32_t)); -#define __rep_new_master __rep_new_master@DB_VERSION_UNIQUE_NAME@ -int __rep_new_master __P((DB_ENV *, REP_CONTROL *, int)); -#define __rep_lockpgno_init __rep_lockpgno_init@DB_VERSION_UNIQUE_NAME@ -int __rep_lockpgno_init __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *)); -#define __rep_unlockpages __rep_unlockpages@DB_VERSION_UNIQUE_NAME@ -int __rep_unlockpages __P((DB_ENV *, u_int32_t)); -#define __rep_lockpages __rep_lockpages@DB_VERSION_UNIQUE_NAME@ -int __rep_lockpages __P((DB_ENV *, int (**)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), DB_LSN *, DB_LSN *, TXN_RECS *, u_int32_t)); -#define __rep_is_client __rep_is_client@DB_VERSION_UNIQUE_NAME@ -int __rep_is_client __P((DB_ENV *)); -#define __rep_send_vote __rep_send_vote@DB_VERSION_UNIQUE_NAME@ -int __rep_send_vote __P((DB_ENV *, DB_LSN *, int, int)); -#define __rep_grow_sites __rep_grow_sites@DB_VERSION_UNIQUE_NAME@ -int __rep_grow_sites __P((DB_ENV *dbenv, int nsites)); -#if defined(__cplusplus) -} -#endif -#endif /* _rep_ext_h_ */ diff --git a/db/log/log_rec.c b/db/log/log_rec.c deleted file mode 100644 index b5a4a52c3..000000000 --- a/db/log/log_rec.c +++ /dev/null @@ -1,696 +0,0 @@ -/*- - * See the file LICENSE for redistribution information. - * - * Copyright (c) 1996-2001 - * Sleepycat Software. All rights reserved. - */ -/* - * Copyright (c) 1995, 1996 - * The President and Fellows of Harvard University. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "db_config.h" - -#ifndef lint -static const char revid[] = "Id: log_rec.c,v 11.69 2001/11/02 16:04:02 margo Exp "; -#endif /* not lint */ - -#ifndef NO_SYSTEM_INCLUDES -#include <sys/types.h> - -#include <string.h> -#endif - -#include "db_int.h" -#include "db_page.h" -#include "db_am.h" -#include "log.h" - -static int __log_check_master __P((DB_ENV *, u_int8_t *, char *)); -static int __log_do_open __P((DB_ENV *, DB_LOG *, - u_int8_t *, char *, DBTYPE, int32_t, db_pgno_t, u_int32_t)); -static int __log_open_file __P((DB_ENV *, - DB_LOG *, __log_register_args *, u_int32_t)); - -/* - * PUBLIC: int __log_register_recover - * PUBLIC: __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *)); - */ -int -__log_register_recover(dbenv, dbtp, lsnp, op, info) - DB_ENV *dbenv; - DBT *dbtp; - DB_LSN *lsnp; - db_recops op; - void *info; -{ - DB_ENTRY *dbe; - DB_LOG *logp; - DB *dbp; - __log_register_args *argp; - int do_rem, ret, t_ret; - u_int32_t flags; - - logp = dbenv->lg_handle; - dbp = NULL; - -#ifdef DEBUG_RECOVER - REC_PRINT(__log_register_print); -#endif - COMPQUIET(lsnp, NULL); - - flags = 0; - - if ((ret = __log_register_read(dbenv, dbtp->data, &argp)) != 0) - goto out; - - if ((argp->opcode == LOG_OPEN && - (DB_REDO(op) || op == DB_TXN_OPENFILES || op == DB_TXN_POPENFILES)) - || ((argp->opcode == LOG_CLOSE || argp->opcode == LOG_RCLOSE) && - DB_UNDO(op))) { - /* - * If we are redoing an open or undoing a close, then we need - * to open a file. We must open the file even if - * the meta page is not yet written as we may be creating it. - */ - if (op == DB_TXN_OPENFILES) - F_SET(logp, DBLOG_FORCE_OPEN); - /* - * If we are applying a log_register record in replication, - * we may be doing so out-of-order with respect to - * a crdel_fileopen record that came before us in the log - * but were in a still-uncommitted transaction. Let the - * underlying log_register know, so that it can postpone - * opening the file until it actually exists. - */ - if (F_ISSET(dbenv, DB_ENV_REP_CLIENT)) - flags = DB_APPLY_LOGREG; - ret = __log_open_file(dbenv, logp, argp, flags); - F_CLR(logp, DBLOG_FORCE_OPEN); - if (ret == ENOENT || ret == EINVAL) { - if ((op == DB_TXN_OPENFILES || op == DB_TXN_POPENFILES) - && argp->name.size != 0 && - (ret = __db_txnlist_delete(dbenv, info, - argp->name.data, argp->fileid, 0)) != 0) - goto out; - ret = 0; - } - } else if (argp->opcode == LOG_OPEN || argp->opcode == LOG_CLOSE || - (argp->opcode == LOG_RCLOSE && op != DB_TXN_POPENFILES)) { - /* - * If we are undoing an open, then we need to close the file. - * - * If the file is deleted, then we can just ignore this close. - * Otherwise, we should usually have a valid dbp we should - * close or whose reference count should be decremented. - * However, if we shut down without closing a file, we may, in - * fact, not have the file open, and that's OK. - */ - do_rem = 0; - MUTEX_THREAD_LOCK(dbenv, logp->mutexp); - if (argp->fileid < logp->dbentry_cnt) { - dbe = &logp->dbentry[argp->fileid]; - - if (dbe->refcount != 1) { - __db_err(dbenv, - "Improper file close. LSN: %lu/%lu.", - (u_long)lsnp->file, (u_long)lsnp->offset); - ret = EINVAL; - goto out; - } - - ret = __db_txnlist_close(info, - argp->fileid, dbe->count); - if ((dbp = TAILQ_FIRST(&dbe->dblist)) != NULL) - (void)dbenv->log_unregister(dbenv, dbp); - do_rem = 1; - } - MUTEX_THREAD_UNLOCK(dbenv, logp->mutexp); - if (do_rem) { - (void)__log_rem_logid(logp, dbp, argp->fileid); - /* - * If remove or rename has closed the file, don't - * sync. - */ - if (dbp != NULL && - (t_ret = dbp->close(dbp, - dbp->mpf == NULL ? DB_NOSYNC : 0)) != 0 && ret == 0) - ret = t_ret; - } - } else if (argp->opcode == LOG_CHECKPOINT && - (DB_UNDO(op) || - op == DB_TXN_OPENFILES || op == DB_TXN_POPENFILES)) { - /* - * It's a checkpoint and we are rolling backward. It - * is possible that the system was shut down and thus - * ended with a stable checkpoint; this file was never - * closed and has therefore not been reopened yet. If - * so, we need to try to open it. - */ - ret = __log_open_file(dbenv, logp, argp, 0); - if (ret == ENOENT || ret == EINVAL) { - if (argp->name.size != 0 && (ret = - __db_txnlist_delete(dbenv, info, - argp->name.data, argp->fileid, 0)) != 0) - goto out; - ret = 0; - } - } - -out: if (argp != NULL) - __os_free(dbenv, argp, 0); - return (ret); -} - -/* - * __log_open_file -- - * Called during log_register recovery. Make sure that we have an - * entry in the dbentry table for this ndx. Returns 0 on success, - * non-zero on error. - */ -static int -__log_open_file(dbenv, lp, argp, flags) - DB_ENV *dbenv; - DB_LOG *lp; - __log_register_args *argp; - u_int32_t flags; -{ - DB_ENTRY *dbe; - DB *dbp; - - /* - * We never re-open temporary files. Temp files are only - * useful during aborts in which case the dbp was entered - * when the file was registered. During recovery, we treat - * temp files as properly deleted files, allowing the open to - * fail and not reporting any errors when recovery fails to - * get a valid dbp from db_fileid_to_db. - */ - if (argp->name.size == 0) { - (void)__log_add_logid(dbenv, lp, NULL, argp->fileid); - return (ENOENT); - } - - /* - * Because of reference counting, we cannot automatically close files - * during recovery, so when we're opening, we have to check that the - * name we are opening is what we expect. If it's not, then we close - * the old file and open the new one. - */ - MUTEX_THREAD_LOCK(dbenv, lp->mutexp); - if (argp->fileid < lp->dbentry_cnt) - dbe = &lp->dbentry[argp->fileid]; - else - dbe = NULL; - - if (dbe != NULL) { - dbe->deleted = 0; - if ((dbp = TAILQ_FIRST(&dbe->dblist)) != NULL) { - if (dbp->meta_pgno != argp->meta_pgno || - memcmp(dbp->fileid, - argp->uid.data, DB_FILE_ID_LEN) != 0) { - MUTEX_THREAD_UNLOCK(dbenv, lp->mutexp); - goto reopen; - } - if (!F_ISSET(lp, DBLOG_RECOVER)) - dbe->refcount++; - MUTEX_THREAD_UNLOCK(dbenv, lp->mutexp); - return (0); - } - } - - MUTEX_THREAD_UNLOCK(dbenv, lp->mutexp); - if (0) { -reopen: (void)dbenv->log_unregister(dbenv, dbp); - (void)__log_rem_logid(lp, dbp, argp->fileid); - dbp->close(dbp, 0); - } - - return (__log_do_open(dbenv, lp, - argp->uid.data, argp->name.data, - argp->ftype, argp->fileid, argp->meta_pgno, flags)); -} - -/* - * log_reopen_file -- close and reopen a db file. - * Must be called when a metadata page changes. - * - * PUBLIC: int __log_reopen_file __P((DB_ENV *, - * PUBLIC: char *, int32_t, u_int8_t *, db_pgno_t, u_int32_t)); - * - */ -int -__log_reopen_file(dbenv, name, ndx, fileid, meta_pgno, flags) - DB_ENV *dbenv; - char *name; - int32_t ndx; - u_int8_t *fileid; - db_pgno_t meta_pgno; - u_int32_t flags; -{ - DB *dbp; - DB_LOG *logp; - DBTYPE ftype; - FNAME *fnp; - LOG *lp; - char *tmp_name; - int ret; - - logp = dbenv->lg_handle; - - if (name == NULL) { - R_LOCK(dbenv, &logp->reginfo); - - lp = logp->reginfo.primary; - - for (fnp = SH_TAILQ_FIRST(&lp->fq, __fname); - fnp != NULL; fnp = SH_TAILQ_NEXT(fnp, q, __fname)) { - if (fnp->ref == 0) /* Entry not in use. */ - continue; - if (memcmp(fnp->ufid, fileid, DB_FILE_ID_LEN) == 0) - break; - } - - if (fnp == 0 || fnp->name_off == INVALID_ROFF) { - __db_err(dbenv, - "metasub recover: non-existent file id"); - return (EINVAL); - } - - name = R_ADDR(&logp->reginfo, fnp->name_off); - ret = __os_strdup(dbenv, name, &tmp_name); - R_UNLOCK(dbenv, &logp->reginfo); - if (ret != 0) - goto out; - name = tmp_name; - } else - tmp_name = NULL; - - if ((ret = __db_fileid_to_db(dbenv, &dbp, ndx, 0)) != 0) - goto out; - ftype = dbp->type; - (void)dbenv->log_unregister(dbenv, dbp); - (void)__log_rem_logid(logp, dbp, ndx); - (void)dbp->close(dbp, 0); - - ret = __log_do_open(dbenv, - logp, fileid, name, ftype, ndx, meta_pgno, flags); - - if (tmp_name != NULL) - __os_free(dbenv, tmp_name, 0); - -out: return (ret); -} - -/* - * __log_do_open -- - * Open files referenced in the log. This is the part of the open that - * is not protected by the thread mutex. - */ -static int -__log_do_open(dbenv, lp, uid, name, ftype, ndx, meta_pgno, flags) - DB_ENV *dbenv; - DB_LOG *lp; - u_int8_t *uid; - char *name; - DBTYPE ftype; - int32_t ndx; - db_pgno_t meta_pgno; - u_int32_t flags; -{ - DB *dbp; - int ret; - u_int8_t zeroid[DB_FILE_ID_LEN]; - - if ((ret = db_create(&dbp, lp->dbenv, 0)) != 0) - return (ret); - - dbp->log_fileid = ndx; - - /* - * This is needed to signal to the locking routines called while - * opening databases that we are potentially undoing a transaction - * from an XA process. Since the XA process does not share - * locks with the aborting transaction this prevents us from - * deadlocking during the open during rollback. - * Because this routine is called either during recovery or during an - * XA_ABORT, we can safely set DB_AM_RECOVER in the dbp since it - * will not be shared with other threads. - */ - F_SET(dbp, DB_AM_RECOVER); - if (meta_pgno != PGNO_BASE_MD) - memcpy(dbp->fileid, uid, DB_FILE_ID_LEN); - dbp->type = ftype; - if ((ret = __db_dbopen(dbp, name, - flags | DB_ODDFILESIZE, __db_omode("rw----"), meta_pgno)) == 0) { - /* - * Verify that we are opening the same file that we were - * referring to when we wrote this log record. - */ - if (meta_pgno != PGNO_BASE_MD && - __log_check_master(dbenv, uid, name) != 0) - goto not_right; - if (memcmp(uid, dbp->fileid, DB_FILE_ID_LEN) != 0) { - memset(zeroid, 0, DB_FILE_ID_LEN); - if (memcmp(dbp->fileid, zeroid, DB_FILE_ID_LEN) != 0) - goto not_right; -skipopen: memcpy(dbp->fileid, uid, DB_FILE_ID_LEN); - } - if (IS_RECOVERING(dbenv) || LF_ISSET(DB_APPLY_LOGREG)) { - /* - * If DB_APPLY_LOGREG is set, we want to register this - * log file with a specific fileid, but we don't want - * to log anything. Pass the flag down into - * the log_register code. - */ - (void)__log_register_int(dbp->dbenv, dbp, name, flags); - (void)__log_add_logid(dbenv, lp, dbp, ndx); - } - return (0); - } else if (ret == ENOENT && LF_ISSET(DB_APPLY_LOGREG)) - goto skipopen; - -not_right: - (void)dbp->close(dbp, 0); - (void)__log_add_logid(dbenv, lp, NULL, ndx); - - return (ENOENT); -} - -static int -__log_check_master(dbenv, uid, name) - DB_ENV *dbenv; - u_int8_t *uid; - char *name; -{ - DB *dbp; - int ret; - - ret = 0; - if ((ret = db_create(&dbp, dbenv, 0)) != 0) - return (ret); - dbp->type = DB_BTREE; - ret = __db_dbopen(dbp, name, 0, __db_omode("rw----"), PGNO_BASE_MD); - - if (ret == 0 && memcmp(uid, dbp->fileid, DB_FILE_ID_LEN) != 0) - ret = EINVAL; - - (void)dbp->close(dbp, 0); - return (ret); -} - -/* - * __log_add_logid -- - * Adds a DB entry to the log's DB entry table. - * - * PUBLIC: int __log_add_logid __P((DB_ENV *, DB_LOG *, DB *, int32_t)); - */ -int -__log_add_logid(dbenv, logp, dbp, ndx) - DB_ENV *dbenv; - DB_LOG *logp; - DB *dbp; - int32_t ndx; -{ - DB *dbtmp; - int32_t i; - int ret; - - ret = 0; - - MUTEX_THREAD_LOCK(dbenv, logp->mutexp); - - /* - * Check if we need to grow the table. Note, ndx is 0-based (the - * index into the DB entry table) an dbentry_cnt is 1-based, the - * number of available slots. - */ - if (logp->dbentry_cnt <= ndx) { - if ((ret = __os_realloc(dbenv, - (ndx + DB_GROW_SIZE) * sizeof(DB_ENTRY), - &logp->dbentry)) != 0) - goto err; - - /* - * We have moved the head of the queue. - * Fix up the queue header of an empty queue or the previous - * pointer of the first element. - */ - for (i = 0; i < logp->dbentry_cnt; i++) { - if ((dbtmp = - TAILQ_FIRST(&logp->dbentry[i].dblist)) == NULL) - TAILQ_INIT(&logp->dbentry[i].dblist); - else - TAILQ_REINSERT_HEAD( - &logp->dbentry[i].dblist, dbtmp, links); - } - - /* Initialize the new entries. */ - for (i = logp->dbentry_cnt; i < ndx + DB_GROW_SIZE; i++) { - logp->dbentry[i].count = 0; - TAILQ_INIT(&logp->dbentry[i].dblist); - logp->dbentry[i].deleted = 0; - logp->dbentry[i].refcount = 0; - } - - logp->dbentry_cnt = i; - } - - if (logp->dbentry[ndx].deleted == 0 && - TAILQ_FIRST(&logp->dbentry[ndx].dblist) == NULL) { - logp->dbentry[ndx].count = 0; - if (dbp != NULL) - TAILQ_INSERT_HEAD(&logp->dbentry[ndx].dblist, - dbp, links); - logp->dbentry[ndx].deleted = dbp == NULL; - logp->dbentry[ndx].refcount = 1; - } else if (!F_ISSET(logp, DBLOG_RECOVER)) { - if (dbp != NULL) - TAILQ_INSERT_HEAD(&logp->dbentry[ndx].dblist, - dbp, links); - logp->dbentry[ndx].refcount++; - } - -err: MUTEX_THREAD_UNLOCK(dbenv, logp->mutexp); - return (ret); -} - -/* - * __db_fileid_to_db -- - * Return the DB corresponding to the specified fileid. - * - * PUBLIC: int __db_fileid_to_db __P((DB_ENV *, DB **, int32_t, int)); - */ -int -__db_fileid_to_db(dbenv, dbpp, ndx, inc) - DB_ENV *dbenv; - DB **dbpp; - int32_t ndx; - int inc; -{ - DB_LOG *logp; - FNAME *fname; - int ret; - char *name; - - ret = 0; - logp = dbenv->lg_handle; - - MUTEX_THREAD_LOCK(dbenv, logp->mutexp); - - /* - * Under XA, a process different than the one issuing DB operations - * may abort a transaction. In this case, recovery routines are run - * by a process that does not necessarily have the file open, so we - * we must open the file explicitly. - */ - if (ndx >= logp->dbentry_cnt || - (!logp->dbentry[ndx].deleted && - TAILQ_FIRST(&logp->dbentry[ndx].dblist) == NULL)) { - if (F_ISSET(logp, DBLOG_RECOVER)) { - ret = ENOENT; - goto err; - } - if (__log_lid_to_fname(logp, ndx, &fname) != 0) { - /* Couldn't find entry; this is a fatal error. */ - __db_err(dbenv, "Missing log fileid entry"); - ret = EINVAL; - goto err; - } - name = R_ADDR(&logp->reginfo, fname->name_off); - - /* - * __log_do_open is called without protection of the - * log thread lock. - */ - MUTEX_THREAD_UNLOCK(dbenv, logp->mutexp); - - /* - * At this point, we are not holding the thread lock, so exit - * directly instead of going through the exit code at the - * bottom. If the __log_do_open succeeded, then we don't need - * to do any of the remaining error checking at the end of this - * routine. - */ - if ((ret = __log_do_open(dbenv, logp, - fname->ufid, name, fname->s_type, - ndx, fname->meta_pgno, 0)) != 0) - return (ret); - - *dbpp = TAILQ_FIRST(&logp->dbentry[ndx].dblist); - return (0); - } - - /* - * Return DB_DELETED if the file has been deleted (it's not an error). - */ - if (logp->dbentry[ndx].deleted) { - ret = DB_DELETED; - if (inc) - logp->dbentry[ndx].count++; - goto err; - } - - /* - * Otherwise return 0, but if we don't have a corresponding DB, - * thats not read only its an error. - */ - if ((*dbpp = TAILQ_FIRST(&logp->dbentry[ndx].dblist)) == NULL) - ret = ENOENT; - - while (ret == 0 && F_ISSET(*dbpp, DB_AM_RDONLY)) - if ((*dbpp = TAILQ_NEXT(*dbpp, links)) == NULL) - ret = ENOENT; - -err: MUTEX_THREAD_UNLOCK(dbenv, logp->mutexp); - return (ret); -} - -/* - * __log_close_files -- - * Close files that were opened by the recovery daemon. We sync the - * file, unless its mpf pointer has been NULLed by a db_remove or - * db_rename. We may not have flushed the log_register record that - * closes the file. - * - * PUBLIC: void __log_close_files __P((DB_ENV *)); - */ -void -__log_close_files(dbenv) - DB_ENV *dbenv; -{ - DB_ENTRY *dbe; - DB_LOG *logp; - DB *dbp; - int32_t i; - - logp = dbenv->lg_handle; - MUTEX_THREAD_LOCK(dbenv, logp->mutexp); - for (i = 0; i < logp->dbentry_cnt; i++) { - dbe = &logp->dbentry[i]; - while ((dbp = TAILQ_FIRST(&dbe->dblist)) != NULL) { - (void)dbenv->log_unregister(dbenv, dbp); - TAILQ_REMOVE(&dbe->dblist, dbp, links); - (void)dbp->close(dbp, dbp->mpf == NULL ? DB_NOSYNC : 0); - } - dbe->deleted = 0; - dbe->refcount = 0; - } - MUTEX_THREAD_UNLOCK(dbenv, logp->mutexp); -} - -/* - * __log_rem_logid - * Remove an entry from the log table. Find the appropriate DB and - * unlink it from the linked list off the table. If the DB is NULL, treat - * this as a simple refcount decrement. - * - * PUBLIC: void __log_rem_logid __P((DB_LOG *, DB *, int32_t)); - */ -void -__log_rem_logid(logp, dbp, ndx) - DB_LOG *logp; - DB *dbp; - int32_t ndx; -{ - DB *xdbp; - - MUTEX_THREAD_LOCK(logp->dbenv, logp->mutexp); - if (--logp->dbentry[ndx].refcount == 0) { - if (dbp == NULL && - (xdbp = TAILQ_FIRST(&logp->dbentry[ndx].dblist)) != NULL) - (void)xdbp->close(xdbp, 0); - TAILQ_INIT(&logp->dbentry[ndx].dblist); - logp->dbentry[ndx].deleted = 0; - } else if (dbp != NULL) - for (xdbp = TAILQ_FIRST(&logp->dbentry[ndx].dblist); - xdbp != NULL; - xdbp = TAILQ_NEXT(xdbp, links)) - if (xdbp == dbp) { - TAILQ_REMOVE(&logp->dbentry[ndx].dblist, - xdbp, links); - break; - } - - MUTEX_THREAD_UNLOCK(logp->dbenv, logp->mutexp); -} - -/* - * __log_lid_to_fname -- - * Traverse the shared-memory region looking for the entry that - * matches the passed log fileid. Returns 0 on success; -1 on error. - * PUBLIC: int __log_lid_to_fname __P((DB_LOG *, int32_t, FNAME **)); - */ -int -__log_lid_to_fname(dblp, lid, fnamep) - DB_LOG *dblp; - int32_t lid; - FNAME **fnamep; -{ - DB_ENV *dbenv; - FNAME *fnp; - LOG *lp; - - dbenv = dblp->dbenv; - lp = dblp->reginfo.primary; - - R_LOCK(dbenv, &dblp->reginfo); - - for (fnp = SH_TAILQ_FIRST(&lp->fq, __fname); - fnp != NULL; fnp = SH_TAILQ_NEXT(fnp, q, __fname)) { - if (fnp->ref == 0) /* Entry not in use. */ - continue; - if (fnp->id == lid) { - *fnamep = fnp; - R_UNLOCK(dbenv, &dblp->reginfo); - return (0); - } - } - - R_UNLOCK(dbenv, &dblp->reginfo); - return (-1); -} diff --git a/db/os_vxworks/os_vx_finit.c b/db/os_vxworks/os_vx_finit.c deleted file mode 100644 index 44ab6913d..000000000 --- a/db/os_vxworks/os_vx_finit.c +++ /dev/null @@ -1,31 +0,0 @@ -/*- - * See the file LICENSE for redistribution information. - * - * Copyright (c) 1999-2001 - * Sleepycat Software. All rights reserved. - */ - -#include "db_config.h" - -#ifndef lint -static const char revid[] = "Id: os_vx_finit.c,v 1.3 2001/06/01 18:35:55 bostic Exp "; -#endif /* not lint */ - -#include "db_int.h" - -/* - * __os_fs_notzero -- - * Return 1 if allocated filesystem blocks are not zeroed. - * - * PUBLIC: int __os_fs_notzero __P((void)); - */ -int -__os_fs_notzero() -{ - /* - * Some VxWorks FS drivers do not zero-fill pages that were never - * explicitly written to the file, they give you random garbage, - * and that breaks Berkeley DB. - */ - return (1); -} |