From 6b3a1715b126d08694f93992fb5e6c838fc0454d Mon Sep 17 00:00:00 2001
From: Rich Prohaska <prohaska@tokutek.com>
Date: Tue, 16 Apr 2013 23:57:28 -0400
Subject: [PATCH] merge 1032 to 1032b. addresses #1231

git-svn-id: file:///svn/toku/tokudb.1032b@7814 c7de825b-a66e-492c-adef-691d508d4ae1
---
 src/errors.c       |  9 +--------
 src/tdbtrace.c     |  2 +-
 src/ydb-internal.h |  9 +++++++--
 src/ydb.c          | 15 +++++++--------
 4 files changed, 16 insertions(+), 19 deletions(-)

diff --git a/src/errors.c b/src/errors.c
index 908d6670b5..bd28c4f771 100644
--- a/src/errors.c
+++ b/src/errors.c
@@ -10,6 +10,7 @@
   The error handling routines for ydb
 */
 
+#include "portability.h"
 #include <stdio.h>
 #include <stdarg.h>
 
@@ -83,10 +84,6 @@ void toku_ydb_error_all_cases(const DB_ENV * env,
     toku__ydb_error_file(env, use_stderr_if_nothing_else, buf);
 }
 
-int toku_ydb_do_error (const DB_ENV *dbenv, int error, const char *string, ...)
-                       __attribute__((__format__(__printf__, 3, 4)));
-
-
 /** Handle all the error cases (but don't do the default thing.) 
     \param dbenv  The environment that is subject to errors
     \param error  The error code
@@ -101,10 +98,6 @@ int toku_ydb_do_error (const DB_ENV *dbenv, int error, const char *fmt, ...) {
     return error;
 }
 
-void toku_locked_env_err(const DB_ENV * env, int error, const char *fmt, ...)
-                           __attribute__((__format__(__printf__, 3, 4)));
-
-
 /** Handle errors on an environment, guarded by the ydb lock 
     \param dbenv  The environment that is subject to errors
     \param error  The error code
diff --git a/src/tdbtrace.c b/src/tdbtrace.c
index 61d679fe78..54e053f5f0 100644
--- a/src/tdbtrace.c
+++ b/src/tdbtrace.c
@@ -267,7 +267,7 @@ static int tokutrace_db_open(DB * db, DB_TXN * txn, const char *fname, const cha
     if (tracefile) {
 	fprintf(tracefile, "db_open %d %d %d %s %s %d %u %d\n",
 		r,
-		dbpairnum(db), txnpairnum(txn), fname, dbname, dbtype, flags, mode);
+		dbpairnum(db), txnpairnum(txn), fname, dbname, (int)dbtype, flags, mode);
     }
     tunlock();
     return r;
diff --git a/src/ydb-internal.h b/src/ydb-internal.h
index 87c6b4db3e..917908f3be 100644
--- a/src/ydb-internal.h
+++ b/src/ydb-internal.h
@@ -88,6 +88,8 @@ struct __toku_dbc_internal {
    Ephemeral locking
 
    ********************************************************* */
+void toku_ydb_lock_init(void);
+void toku_ydb_lock_destroy(void);
 void toku_ydb_lock(void);
 void toku_ydb_unlock(void);
 
@@ -121,7 +123,9 @@ void toku_ydb_error_all_cases(const DB_ENV * env,
                               const char *fmt, va_list ap)
     __attribute__((format (printf, 5, 0)))
     __attribute__((__visibility__("default"))); // this is needed by the C++ interface. 
-int toku_ydb_do_error (const DB_ENV *, int, const char *, ...);
+
+int toku_ydb_do_error (const DB_ENV *dbenv, int error, const char *string, ...)
+                       __attribute__((__format__(__printf__, 3, 4)));
 
 /* Location specific debug print-outs */
 void toku_ydb_barf(void);
@@ -129,6 +133,7 @@ void toku_ydb_notef(const char *, ...);
 
 /* Environment related errors */
 int toku_env_is_panicked(DB_ENV *dbenv);
-void toku_locked_env_err(const DB_ENV * env, int error, const char *fmt, ...);
+void toku_locked_env_err(const DB_ENV * env, int error, const char *fmt, ...) 
+                         __attribute__((__format__(__printf__, 3, 4)));
 
 #endif
diff --git a/src/ydb.c b/src/ydb.c
index 1abb7f9cab..e866df5e00 100644
--- a/src/ydb.c
+++ b/src/ydb.c
@@ -772,11 +772,11 @@ static int toku_env_txn_stat(DB_ENV * env, DB_TXN_STAT ** statp, u_int32_t flags
 }
 
 #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 1
-void toku_default_errcall(const char *errpfx, char *msg) {
+static void toku_default_errcall(const char *errpfx, char *msg) {
     fprintf(stderr, "YDB: %s: %s", errpfx, msg);
 }
 #else
-void toku_default_errcall(const DB_ENV *env, const char *errpfx, const char *msg) {
+static void toku_default_errcall(const DB_ENV *env, const char *errpfx, const char *msg) {
     env = env;
     fprintf(stderr, "YDB: %s: %s", errpfx, msg);
 }
@@ -1135,7 +1135,6 @@ int txn_commit(DB_TXN * txn, u_int32_t flags) {
 }
 #endif
 
-int log_compare(const DB_LSN * a, const DB_LSN * b) __attribute__((__noreturn__));
 int log_compare(const DB_LSN * a, const DB_LSN * b) {
     toku_ydb_lock();
     fprintf(stderr, "%s:%d log_compare(%p,%p)\n", __FILE__, __LINE__, a, b);
@@ -2970,7 +2969,7 @@ static int toku_db_put_noassociate(DB * db, DB_TXN * txn, DBT * key, DBT * data,
     } else {
         unsigned int limit = nodesize / (3*BRT_FANOUT-1);
         if (key->size >= limit || data->size >= limit)
-            return toku_ydb_do_error(db->dbenv, EINVAL, "The largest key or data item allowed is %d bytes", limit);
+            return toku_ydb_do_error(db->dbenv, EINVAL, "The largest key or data item allowed is %u bytes", limit);
     }
     u_int32_t lock_flags = get_prelocked_flags(flags, txn);
     flags &= ~lock_flags;
@@ -3219,7 +3218,7 @@ cleanup:
     return r;
 }
 
-int toku_db_pre_acquire_read_lock(DB *db, DB_TXN *txn, const DBT *key_left, const DBT *val_left, const DBT *key_right, const DBT *val_right) {
+static int toku_db_pre_acquire_read_lock(DB *db, DB_TXN *txn, const DBT *key_left, const DBT *val_left, const DBT *key_right, const DBT *val_right) {
     HANDLE_PANICKED_DB(db);
     if (!db->i->lt || !txn) return EINVAL;
     //READ_UNCOMMITTED transactions do not need read locks.
@@ -3236,7 +3235,7 @@ int toku_db_pre_acquire_read_lock(DB *db, DB_TXN *txn, const DBT *key_left, cons
     return r;
 }
 
-int toku_db_pre_acquire_table_lock(DB *db, DB_TXN *txn) {
+static int toku_db_pre_acquire_table_lock(DB *db, DB_TXN *txn) {
     HANDLE_PANICKED_DB(db);
     if (!db->i->lt || !txn) return EINVAL;
 
@@ -3346,14 +3345,14 @@ static int locked_db_get (DB * db, DB_TXN * txn, DBT * key, DBT * data, u_int32_
     toku_ydb_lock(); int r = autotxn_db_get(db, txn, key, data, flags); toku_ydb_unlock(); return r;
 }
 
-int locked_db_pre_acquire_read_lock(DB *db, DB_TXN *txn, const DBT *key_left, const DBT *val_left, const DBT *key_right, const DBT *val_right) {
+static int locked_db_pre_acquire_read_lock(DB *db, DB_TXN *txn, const DBT *key_left, const DBT *val_left, const DBT *key_right, const DBT *val_right) {
     toku_ydb_lock();
     int r = toku_db_pre_acquire_read_lock(db, txn, key_left, val_left, key_right, val_right);
     toku_ydb_unlock();
     return r;
 }
 
-int locked_db_pre_acquire_table_lock(DB *db, DB_TXN *txn) {
+static int locked_db_pre_acquire_table_lock(DB *db, DB_TXN *txn) {
     toku_ydb_lock();
     int r = toku_db_pre_acquire_table_lock(db, txn);
     toku_ydb_unlock();
-- 
2.30.9