X-Git-Url: https://code.citadel.org/?p=citadel.git;a=blobdiff_plain;f=citadel%2Fserver%2Fbackends%2Fberkeley_db%2Fberkeley_db.c;h=56a5f14fb1ccfcfba63ae68d9ddfe58385ee6732;hp=b36c3c1058459969d7873bd717c3c300a4392b3c;hb=HEAD;hpb=0f29bb4d04dd7a16f31f008fea15d2d69068f708 diff --git a/citadel/server/backends/berkeley_db/berkeley_db.c b/citadel/server/backends/berkeley_db/berkeley_db.c index b36c3c105..56a5f14fb 100644 --- a/citadel/server/backends/berkeley_db/berkeley_db.c +++ b/citadel/server/backends/berkeley_db/berkeley_db.c @@ -215,10 +215,8 @@ void bdb_checkpoint(void) { } -// Open the various tables we'll be using. Any table which -// does not exist should be created. Note that we don't need a -// critical section here, because there aren't any active threads -// manipulating the database yet. +// Open the various tables we'll be using. Any table which does not exist should be created. Note that we don't need a +// critical section here, because there aren't any active threads manipulating the database yet. void bdb_open_databases(void) { int ret; int i; @@ -266,7 +264,6 @@ void bdb_open_databases(void) { } for (i = 0; i < MAXCDB; ++i) { - syslog(LOG_INFO, "bdb: mounting database %02x", i); ret = db_create(&bdb_table[i], bdb_env, 0); // Create a database handle if (ret) { syslog(LOG_ERR, "bdb: db_create: %s", db_strerror(ret)); @@ -312,7 +309,6 @@ void bdb_close_databases(void) { // close the tables syslog(LOG_INFO, "bdb: closing databases"); for (i = 0; i < MAXCDB; ++i) { - syslog(LOG_INFO, "bdb: closing database %02x", i); ret = bdb_table[i]->close(bdb_table[i], 0); if (ret) { syslog(LOG_ERR, "bdb: db_close: %s", db_strerror(ret)); @@ -360,8 +356,7 @@ void bdb_decompress_if_necessary(DBT *d) { destLen = (uLongf) zheader.uncompressed_len; uncompressed_data = malloc(zheader.uncompressed_len); - if (uncompress((Bytef *) uncompressed_data, - (uLongf *) &destLen, (const Bytef *) compressed_data, (uLong) sourceLen) != Z_OK) { + if (uncompress((Bytef *) uncompressed_data, (uLongf *) &destLen, (const Bytef *) compressed_data, (uLong) sourceLen) != Z_OK) { syslog(LOG_ERR, "bdb: uncompress() error"); bdb_abort(); } @@ -558,8 +553,8 @@ struct cdbkeyval bdb_next_item(int cdb) { memset(&kv, 0, sizeof(struct cdbkeyval)); // reuse memory from the previous call. - TSD->dbkey[cdb].flags = DB_DBT_MALLOC; - TSD->dbdata[cdb].flags = DB_DBT_MALLOC; + TSD->dbkey[cdb].flags = DB_DBT_REALLOC; + TSD->dbdata[cdb].flags = DB_DBT_REALLOC; assert(TSD->cursors[cdb] != NULL); ret = TSD->cursors[cdb]->c_get(TSD->cursors[cdb], &TSD->dbkey[cdb], &TSD->dbdata[cdb], DB_NEXT); @@ -641,6 +636,7 @@ void bdb_tick(void) { } } + // Calling this function activates the Berkeley DB back end. void bdb_init_backend(void) { @@ -662,7 +658,7 @@ void bdb_init_backend(void) { cdb_tick = bdb_tick; // Some functions in this backend need to store some per-thread data. - // We crerate the key here, during module initialization. + // We create the key here, during module initialization. if (pthread_key_create(&bdb_thread_key, NULL) != 0) { syslog(LOG_ERR, "pthread_key_create() : %m"); exit(CTDLEXIT_THREAD);