X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fdatabase_sleepycat.c;h=3a5a04ee8822ab2ad12af4db956e800967484df8;hb=2e5bfef2c1708874507a51c9469b2c181b5523f4;hp=6a2f0be62f28127353b00ce9eea8b1b60fbfa214;hpb=5629373d62f7a65f9bbef3a0b664cfc7ee598482;p=citadel.git diff --git a/citadel/database_sleepycat.c b/citadel/database_sleepycat.c index 6a2f0be62..3a5a04ee8 100644 --- a/citadel/database_sleepycat.c +++ b/citadel/database_sleepycat.c @@ -80,7 +80,7 @@ static void txabort(DB_TXN *tid) { ret = tid->abort(tid); if (ret) { - lprintf(1, "cdb_*: txn_abort: %s\n", db_strerror(ret)); + lprintf(CTDL_EMERG, "cdb_*: txn_abort: %s\n", db_strerror(ret)); abort(); } } @@ -92,7 +92,7 @@ static void txcommit(DB_TXN *tid) { ret = tid->commit(tid, 0); if (ret) { - lprintf(1, "cdb_*: txn_commit: %s\n", db_strerror(ret)); + lprintf(CTDL_EMERG, "cdb_*: txn_commit: %s\n", db_strerror(ret)); abort(); } } @@ -104,7 +104,7 @@ static void txbegin(DB_TXN **tid) { ret = dbenv->txn_begin(dbenv, NULL, tid, 0); if (ret) { - lprintf(1, "cdb_*: txn_begin: %s\n", db_strerror(ret)); + lprintf(CTDL_EMERG, "cdb_*: txn_begin: %s\n", db_strerror(ret)); abort(); } } @@ -113,7 +113,7 @@ static void cclose(DBC *cursor) { int ret; if ((ret = cursor->c_close(cursor))) { - lprintf(1, "cdb_*: c_close: %s\n", db_strerror(ret)); + lprintf(CTDL_EMERG, "cdb_*: c_close: %s\n", db_strerror(ret)); abort(); } } @@ -125,7 +125,7 @@ static void bailIfCursor(DBC **cursors, const char *msg) for (i = 0; i < MAXCDB; i++) if (cursors[i] != NULL) { - lprintf(1, "cdb_*: cursor still in progress on cdb %d: %s\n", i, msg); + lprintf(CTDL_EMERG, "cdb_*: cursor still in progress on cdb %d: %s\n", i, msg); abort(); } } @@ -137,7 +137,7 @@ static void check_handles(void *arg) { bailIfCursor(tsd->cursors, "in check_handles"); if (tsd->tid != NULL) { - lprintf(1, "cdb_*: transaction still in progress!"); + lprintf(CTDL_EMERG, "cdb_*: transaction still in progress!"); abort(); } } @@ -204,20 +204,20 @@ static void cdb_cull_logs(void) { char **file, **list; char errmsg[SIZ]; - lprintf(5, "Database log file cull started.\n"); + lprintf(CTDL_INFO, "Database log file cull started.\n"); flags = DB_ARCH_ABS; /* Get the list of names. */ if ((ret = dbenv->log_archive(dbenv, &list, flags)) != 0) { - lprintf(1, "cdb_cull_logs: %s\n", db_strerror(ret)); + lprintf(CTDL_ERR, "cdb_cull_logs: %s\n", db_strerror(ret)); return; } /* Print the list of names. */ if (list != NULL) { for (file = list; *file != NULL; ++file) { - lprintf(9, "Deleting log: %s\n", *file); + lprintf(CTDL_DEBUG, "Deleting log: %s\n", *file); ret = unlink(*file); if (ret != 0) { snprintf(errmsg, sizeof(errmsg), @@ -235,7 +235,7 @@ static void cdb_cull_logs(void) { free(list); } - lprintf(5, "Database log file cull ended.\n"); + lprintf(CTDL_INFO, "Database log file cull ended.\n"); } @@ -252,7 +252,7 @@ static void cdb_checkpoint(void) { 0); if (ret != 0) { - lprintf(1, "cdb_checkpoint: txn_checkpoint: %s\n", + lprintf(CTDL_EMERG, "cdb_checkpoint: txn_checkpoint: %s\n", db_strerror(ret)); abort(); } @@ -282,11 +282,11 @@ void open_databases(void) getcwd(dbdirname, sizeof dbdirname); strcat(dbdirname, "/data"); - lprintf(9, "cdb_*: open_databases() starting\n"); - lprintf(9, "Compiled db: %s\n", DB_VERSION_STRING); - lprintf(5, " Linked db: %s\n", db_version(NULL, NULL, NULL)); + lprintf(CTDL_DEBUG, "cdb_*: open_databases() starting\n"); + lprintf(CTDL_DEBUG, "Compiled db: %s\n", DB_VERSION_STRING); + lprintf(CTDL_INFO, " Linked db: %s\n", db_version(NULL, NULL, NULL)); #ifdef HAVE_ZLIB - lprintf(5, "Linked zlib: %s\n", zlibVersion()); + lprintf(CTDL_INFO, "Linked zlib: %s\n", zlibVersion()); #endif /* @@ -295,11 +295,11 @@ void open_databases(void) */ mkdir(dbdirname, 0700); - lprintf(9, "cdb_*: Setting up DB environment\n"); + lprintf(CTDL_DEBUG, "cdb_*: Setting up DB environment\n"); db_env_set_func_yield(sched_yield); ret = db_env_create(&dbenv, 0); if (ret) { - lprintf(1, "cdb_*: db_env_create: %s\n", db_strerror(ret)); + lprintf(CTDL_EMERG, "cdb_*: db_env_create: %s\n", db_strerror(ret)); exit(ret); } dbenv->set_errpfx(dbenv, "citserver"); @@ -310,35 +310,35 @@ void open_databases(void) */ ret = dbenv->set_cachesize(dbenv, 0, 64 * 1024, 0); if (ret) { - lprintf(1, "cdb_*: set_cachesize: %s\n", db_strerror(ret)); + lprintf(CTDL_EMERG, "cdb_*: set_cachesize: %s\n", db_strerror(ret)); dbenv->close(dbenv, 0); exit(ret); } if ((ret = dbenv->set_lk_detect(dbenv, DB_LOCK_DEFAULT))) { - lprintf(1, "cdb_*: set_lk_detect: %s\n", db_strerror(ret)); + lprintf(CTDL_EMERG, "cdb_*: set_lk_detect: %s\n", db_strerror(ret)); dbenv->close(dbenv, 0); exit(ret); } flags = DB_CREATE|DB_RECOVER|DB_INIT_MPOOL|DB_PRIVATE|DB_INIT_TXN| DB_INIT_LOCK|DB_THREAD; - lprintf(9, "dbenv->open(dbenv, %s, %d, 0)\n", dbdirname, flags); + lprintf(CTDL_DEBUG, "dbenv->open(dbenv, %s, %d, 0)\n", dbdirname, flags); ret = dbenv->open(dbenv, dbdirname, flags, 0); if (ret) { - lprintf(1, "cdb_*: dbenv->open: %s\n", db_strerror(ret)); + lprintf(CTDL_DEBUG, "cdb_*: dbenv->open: %s\n", db_strerror(ret)); dbenv->close(dbenv, 0); exit(ret); } - lprintf(7, "cdb_*: Starting up DB\n"); + lprintf(CTDL_INFO, "cdb_*: Starting up DB\n"); for (i = 0; i < MAXCDB; ++i) { /* Create a database handle */ ret = db_create(&dbp[i], dbenv, 0); if (ret) { - lprintf(1, "cdb_*: db_create: %s\n", db_strerror(ret)); + lprintf(CTDL_DEBUG, "cdb_*: db_create: %s\n", db_strerror(ret)); exit(ret); } @@ -358,19 +358,19 @@ void open_databases(void) , 0600); if (ret) { - lprintf(1, "cdb_*: db_open[%d]: %s\n", i, db_strerror(ret)); + lprintf(CTDL_EMERG, "cdb_*: db_open[%d]: %s\n", i, db_strerror(ret)); exit(ret); } } if ((ret = pthread_key_create(&tsdkey, dest_tsd))) { - lprintf(1, "cdb_*: pthread_key_create: %s\n", strerror(ret)); + lprintf(CTDL_EMERG, "cdb_*: pthread_key_create: %s\n", strerror(ret)); exit(1); } cdb_allocate_tsd(); CtdlRegisterSessionHook(cdb_checkpoint, EVT_TIMER); - lprintf(9, "cdb_*: open_databases() finished\n"); + lprintf(CTDL_DEBUG, "cdb_*: open_databases() finished\n"); } @@ -386,15 +386,15 @@ void close_databases(void) cdb_free_tsd(); if ((ret = dbenv->txn_checkpoint(dbenv, 0, 0, 0))) { - lprintf(1, "cdb_*: txn_checkpoint: %s\n", db_strerror(ret)); + lprintf(CTDL_EMERG, "cdb_*: txn_checkpoint: %s\n", db_strerror(ret)); abort(); } for (a = 0; a < MAXCDB; ++a) { - lprintf(7, "cdb_*: Closing database %d\n", a); + lprintf(CTDL_INFO, "cdb_*: Closing database %d\n", a); ret = dbp[a]->close(dbp[a], 0); if (ret) { - lprintf(1, "cdb_*: db_close: %s\n", db_strerror(ret)); + lprintf(CTDL_EMERG, "cdb_*: db_close: %s\n", db_strerror(ret)); abort(); } @@ -403,7 +403,7 @@ void close_databases(void) /* Close the handle. */ ret = dbenv->close(dbenv, 0); if (ret) { - lprintf(1, "cdb_*: DBENV->close: %s\n", db_strerror(ret)); + lprintf(CTDL_EMERG, "cdb_*: DBENV->close: %s\n", db_strerror(ret)); abort(); } } @@ -440,7 +440,7 @@ void cdb_decompress_if_necessary(struct cdbdata *cdb) { compressed_data, sourceLen ) != Z_OK) { - lprintf(1, "uncompress() error\n"); + lprintf(CTDL_EMERG, "uncompress() error\n"); abort(); } @@ -498,7 +498,7 @@ int cdb_store(int cdb, (uLongf) cdatalen, 1 ) != Z_OK) { - lprintf(1, "compress2() error\n"); + lprintf(CTDL_EMERG, "compress2() error\n"); abort(); } zheader.compressed_len = (size_t) destLen; @@ -519,8 +519,7 @@ int cdb_store(int cdb, 0); /* flags */ if (ret) { - lprintf(1, "cdb_store(%d): %s\n", cdb, - db_strerror(ret)); + lprintf(CTDL_EMERG, "cdb_store(%d): %s\n", cdb, db_strerror(ret)); abort(); } #ifdef HAVE_ZLIB @@ -549,8 +548,7 @@ int cdb_store(int cdb, } else { - lprintf(1, "cdb_store(%d): %s\n", cdb, - db_strerror(ret)); + lprintf(CTDL_EMERG, "cdb_store(%d): %s\n", cdb, db_strerror(ret)); abort(); } } @@ -585,8 +583,7 @@ int cdb_delete(int cdb, void *key, int keylen) ret = dbp[cdb]->del(dbp[cdb], MYTID, &dkey, 0); if (ret) { - lprintf(1, "cdb_delete(%d): %s\n", cdb, - db_strerror(ret)); + lprintf(CTDL_EMERG, "cdb_delete(%d): %s\n", cdb, db_strerror(ret)); if (ret != DB_NOTFOUND) abort(); } @@ -608,8 +605,7 @@ int cdb_delete(int cdb, void *key, int keylen) } else { - lprintf(1, "cdb_delete(%d): %s\n", cdb, - db_strerror(ret)); + lprintf(CTDL_EMERG, "cdb_delete(%d): %s\n", cdb, db_strerror(ret)); abort(); } } @@ -633,7 +629,7 @@ static DBC *localcursor(int cdb) if (ret) { - lprintf(1, "localcursor: %s\n", db_strerror(ret)); + lprintf(CTDL_EMERG, "localcursor: %s\n", db_strerror(ret)); abort(); } @@ -683,7 +679,7 @@ struct cdbdata *cdb_fetch(int cdb, void *key, int keylen) if ((ret != 0) && (ret != DB_NOTFOUND)) { - lprintf(1, "cdb_fetch(%d): %s\n", cdb, db_strerror(ret)); + lprintf(CTDL_EMERG, "cdb_fetch(%d): %s\n", cdb, db_strerror(ret)); abort(); } @@ -692,7 +688,7 @@ struct cdbdata *cdb_fetch(int cdb, void *key, int keylen) if (tempcdb == NULL) { - lprintf(2, "cdb_fetch: Cannot allocate memory for tempcdb\n"); + lprintf(CTDL_EMERG, "cdb_fetch: Cannot allocate memory for tempcdb\n"); abort(); } @@ -740,7 +736,7 @@ void cdb_rewind(int cdb) */ ret = dbp[cdb]->cursor(dbp[cdb], MYTID, &MYCURSORS[cdb], 0); if (ret) { - lprintf(1, "cdb_rewind: db_cursor: %s\n", db_strerror(ret)); + lprintf(CTDL_EMERG, "cdb_rewind: db_cursor: %s\n", db_strerror(ret)); abort(); } } @@ -766,7 +762,7 @@ struct cdbdata *cdb_next_item(int cdb) if (ret) { if (ret != DB_NOTFOUND) { - lprintf(1, "cdb_next_item(%d): %s\n", + lprintf(CTDL_EMERG, "cdb_next_item(%d): %s\n", cdb, db_strerror(ret)); abort(); } @@ -797,7 +793,7 @@ void cdb_begin_transaction(void) { if (MYTID != NULL) { - lprintf(1, "cdb_begin_transaction: ERROR: nested transaction\n"); + lprintf(CTDL_EMERG, "cdb_begin_transaction: ERROR: nested transaction\n"); abort(); } @@ -809,14 +805,14 @@ void cdb_end_transaction(void) { for (i = 0; i < MAXCDB; i++) if (MYCURSORS[i] != NULL) { - lprintf(1, "cdb_end_transaction: WARNING: cursor %d still open at transaction end\n", i); + lprintf(CTDL_WARNING, "cdb_end_transaction: WARNING: cursor %d still open at transaction end\n", i); cclose(MYCURSORS[i]); MYCURSORS[i] = NULL; } if (MYTID == NULL) { - lprintf(1, "cdb_end_transaction: ERROR: txcommit(NULL) !!\n"); + lprintf(CTDL_EMERG, "cdb_end_transaction: ERROR: txcommit(NULL) !!\n"); abort(); } else @@ -836,7 +832,7 @@ void cdb_trunc(int cdb) if (MYTID != NULL) { - lprintf(1, "cdb_trunc must not be called in a transaction.\n"); + lprintf(CTDL_EMERG, "cdb_trunc must not be called in a transaction.\n"); abort(); } else @@ -858,8 +854,7 @@ void cdb_trunc(int cdb) } else { - lprintf(1, "cdb_truncate(%d): %s\n", cdb, - db_strerror(ret)); + lprintf(CTDL_EMERG, "cdb_truncate(%d): %s\n", cdb, db_strerror(ret)); abort(); } }