Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

db_server_int.h

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 2000-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: db_server_int.h,v 12.4 2005/08/08 14:52:30 bostic Exp $
00008  */
00009 
00010 #ifndef _DB_SERVER_INT_H_
00011 #define _DB_SERVER_INT_H_
00012 
00013 #define DB_SERVER_TIMEOUT       300     /* 5 minutes */
00014 #define DB_SERVER_MAXTIMEOUT    1200    /* 20 minutes */
00015 #define DB_SERVER_IDLETIMEOUT   86400   /* 1 day */
00016 
00017 /*
00018  * Ignore/mask off the following env->open flags:
00019  * Most are illegal for a client to specify as they would control
00020  * server resource usage.  We will just ignore them.
00021  *      DB_LOCKDOWN
00022  *      DB_PRIVATE
00023  *      DB_RECOVER
00024  *      DB_RECOVER_FATAL
00025  *      DB_SYSTEM_MEM
00026  *      DB_USE_ENVIRON, DB_USE_ENVIRON_ROOT     - handled on client
00027  */
00028 #define DB_SERVER_FLAGMASK      (                                       \
00029 DB_LOCKDOWN | DB_PRIVATE | DB_RECOVER | DB_RECOVER_FATAL |              \
00030 DB_SYSTEM_MEM | DB_USE_ENVIRON | DB_USE_ENVIRON_ROOT)
00031 
00032 #define CT_CURSOR       0x001           /* Cursor */
00033 #define CT_DB           0x002           /* Database */
00034 #define CT_ENV          0x004           /* Env */
00035 #define CT_TXN          0x008           /* Txn */
00036 
00037 #define CT_JOIN         0x10000000      /* Join cursor component */
00038 #define CT_JOINCUR      0x20000000      /* Join cursor */
00039 
00040 typedef struct home_entry home_entry;
00041 struct home_entry {
00042         LIST_ENTRY(home_entry) entries;
00043         char *home;
00044         char *dir;
00045         char *name;
00046         char *passwd;
00047 };
00048 
00049 /*
00050  * Data needed for sharing handles.
00051  * To share an env handle, on the open call, they must have matching
00052  * env flags, and matching set_flags.
00053  *
00054  * To share a db handle on the open call, the db, subdb and flags must
00055  * all be the same.
00056  */
00057 #define DB_SERVER_ENVFLAGS       (                                      \
00058 DB_INIT_CDB | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL |              \
00059 DB_INIT_TXN | DB_JOINENV)
00060 
00061 #define DB_SERVER_DBFLAGS        (DB_NOMMAP | DB_RDONLY | DB_READ_UNCOMMITTED)
00062 #define DB_SERVER_DBNOSHARE      (DB_EXCL | DB_TRUNCATE)
00063 
00064 typedef struct ct_envdata ct_envdata;
00065 typedef struct ct_dbdata ct_dbdata;
00066 struct ct_envdata {
00067         u_int32_t       envflags;
00068         u_int32_t       onflags;
00069         u_int32_t       offflags;
00070         home_entry      *home;
00071 };
00072 
00073 struct ct_dbdata {
00074         u_int32_t       dbflags;
00075         u_int32_t       setflags;
00076         char            *db;
00077         char            *subdb;
00078         DBTYPE          type;
00079 };
00080 
00081 /*
00082  * We maintain an activity timestamp for each handle.  However, we
00083  * set it to point, possibly to the ct_active field of its own handle
00084  * or it may point to the ct_active field of a parent.  In the case
00085  * of nested transactions and any cursors within transactions it must
00086  * point to the ct_active field of the ultimate parent of the transaction
00087  * no matter how deeply it is nested.
00088  */
00089 typedef struct ct_entry ct_entry;
00090 struct ct_entry {
00091         LIST_ENTRY(ct_entry) entries;           /* List of entries */
00092         union {
00093 #ifdef __cplusplus
00094                 DbEnv *envp;                    /* H_ENV */
00095                 DbTxn *txnp;                    /* H_TXN */
00096                 Db *dbp;                        /* H_DB */
00097                 Dbc *dbc;                       /* H_CURSOR */
00098 #else
00099                 DB_ENV *envp;                   /* H_ENV */
00100                 DB_TXN *txnp;                   /* H_TXN */
00101                 DB *dbp;                        /* H_DB */
00102                 DBC *dbc;                       /* H_CURSOR */
00103 #endif
00104                 void *anyp;
00105         } handle_u;
00106         union {                                 /* Private data per type */
00107                 ct_envdata      envdp;          /* Env info */
00108                 ct_dbdata       dbdp;           /* Db info */
00109         } private_u;
00110         long ct_id;                             /* Client ID */
00111         long *ct_activep;                       /* Activity timestamp pointer*/
00112         long *ct_origp;                         /* Original timestamp pointer*/
00113         long ct_active;                         /* Activity timestamp */
00114         long ct_timeout;                        /* Resource timeout */
00115         long ct_idle;                           /* Idle timeout */
00116         u_int32_t ct_refcount;                  /* Ref count for sharing */
00117         u_int32_t ct_type;                      /* This entry's type */
00118         struct ct_entry *ct_parent;             /* Its parent */
00119         struct ct_entry *ct_envparent;          /* Its environment */
00120 };
00121 
00122 #define ct_envp handle_u.envp
00123 #define ct_txnp handle_u.txnp
00124 #define ct_dbp handle_u.dbp
00125 #define ct_dbc handle_u.dbc
00126 #define ct_anyp handle_u.anyp
00127 
00128 #define ct_envdp private_u.envdp
00129 #define ct_dbdp private_u.dbdp
00130 
00131 extern int __dbsrv_verbose;
00132 
00133 /*
00134  * Get ctp and activate it.
00135  * Assumes local variable 'replyp'.
00136  * NOTE: May 'return' from macro.
00137  */
00138 #define ACTIVATE_CTP(ctp, id, type) {           \
00139         (ctp) = get_tableent(id);               \
00140         if ((ctp) == NULL) {                    \
00141                 replyp->status = DB_NOSERVER_ID;\
00142                 return;                         \
00143         }                                       \
00144         DB_ASSERT((ctp)->ct_type & (type));     \
00145         __dbsrv_active(ctp);                    \
00146 }
00147 
00148 #define FREE_IF_CHANGED(dbenv, p, orig) do {    \
00149         if ((p) != NULL && (p) != (orig))       \
00150                 __os_ufree((dbenv), (p));       \
00151 } while (0)
00152 
00153 #endif  /* !_DB_SERVER_INT_H_ */

Generated on Sun Dec 25 12:14:22 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2