db

log_method.c

Go to the documentation of this file.
00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 1999, 2000
00005  * Sleepycat Software. All rights reserved.
00006  */
00007 #include "config.h"
00008 
00009 #ifndef lint
00010 static const char revid[] = "$Id: log__method_8c-source.html,v 1.1 2008年06月08日 10:20:24 sebdiaz Exp $";
00011 #endif /* not lint */
00012 
00013 #ifndef NO_SYSTEM_INCLUDES
00014 #include <sys/types.h>
00015 
00016 #include <errno.h>
00017 #include <stdlib.h>
00018 #include <string.h>
00019 #include <unistd.h>
00020 #endif
00021 
00022 #ifdef HAVE_RPC
00023 #include "db_server.h"
00024 #endif
00025 
00026 #include "db_int.h"
00027 #include "log.h"
00028 
00029 #ifdef HAVE_RPC
00030 #include "gen_client_ext.h"
00031 #include "rpc_client_ext.h"
00032 #endif
00033 
00034 static int __log_set_lg_max __P((DB_ENV *, u_int32_t));
00035 static int __log_set_lg_bsize __P((DB_ENV *, u_int32_t));
00036 static int __log_set_lg_dir __P((DB_ENV *, const char *));
00037 
00038 /*
00039  * CDB___log_dbenv_create --
00040  * Log specific initialization of the DB_ENV structure.
00041  *
00042  * PUBLIC: void CDB___log_dbenv_create __P((DB_ENV *));
00043  */
00044 void
00045 CDB___log_dbenv_create(dbenv)
00046 DB_ENV *dbenv;
00047 {
00048 dbenv->lg_bsize = LG_BSIZE_DEFAULT;
00049 dbenv->set_lg_bsize = __log_set_lg_bsize;
00050 
00051 dbenv->lg_max = LG_MAX_DEFAULT;
00052 dbenv->set_lg_max = __log_set_lg_max;
00053 
00054 dbenv->set_lg_dir = __log_set_lg_dir;
00055 #ifdef HAVE_RPC
00056 /*
00057  * If we have a client, overwrite what we just setup to
00058  * point to client functions.
00059  */
00060 if (F_ISSET(dbenv, DB_ENV_RPCCLIENT)) {
00061 dbenv->set_lg_bsize = __dbcl_set_lg_bsize;
00062 dbenv->set_lg_max = __dbcl_set_lg_max;
00063 dbenv->set_lg_dir = __dbcl_set_lg_dir;
00064 }
00065 #endif
00066 }
00067 
00068 /*
00069  * __log_set_lg_bsize --
00070  * Set the log buffer size.
00071  */
00072 static int
00073 __log_set_lg_bsize(dbenv, lg_bsize)
00074 DB_ENV *dbenv;
00075 u_int32_t lg_bsize;
00076 {
00077 ENV_ILLEGAL_AFTER_OPEN(dbenv, "set_lg_bsize");
00078 
00079 /* Let's not be silly. */
00080 if (lg_bsize > dbenv->lg_max / 4) {
00081 CDB___db_err(dbenv, "log buffer size must be <= log file size / 4");
00082 return (EINVAL);
00083 }
00084 
00085 dbenv->lg_bsize = lg_bsize;
00086 return (0);
00087 }
00088 
00089 /*
00090  * __log_set_lg_max --
00091  * Set the maximum log file size.
00092  */
00093 static int
00094 __log_set_lg_max(dbenv, lg_max)
00095 DB_ENV *dbenv;
00096 u_int32_t lg_max;
00097 {
00098 ENV_ILLEGAL_AFTER_OPEN(dbenv, "set_lg_max");
00099 
00100 /* Let's not be silly. */
00101 if (lg_max < dbenv->lg_bsize * 4) {
00102 CDB___db_err(dbenv, "log file size must be >= log buffer size * 4");
00103 return (EINVAL);
00104 }
00105 
00106 dbenv->lg_max = lg_max;
00107 return (0);
00108 }
00109 
00110 /*
00111  * __log_set_lg_dir --
00112  * Set the log file directory.
00113  */
00114 static int
00115 __log_set_lg_dir(dbenv, dir)
00116 DB_ENV *dbenv;
00117 const char *dir;
00118 {
00119 if (dbenv->db_log_dir != NULL)
00120 CDB___os_freestr(dbenv->db_log_dir);
00121 return (CDB___os_strdup(dbenv, dir, &dbenv->db_log_dir));
00122 }

Generated on Sun Jun 8 10:56:38 2008 for GNUmifluz by doxygen 1.5.5

AltStyle によって変換されたページ (->オリジナル) /