mirror of
https://github.com/fairwaves/openbts-2.8.git
synced 2025-11-01 20:43:30 +00:00
Brandon Creighton's patch: A lot of refactoring, but separates global object creation from initialization. Allows for logging of database initialization failures.
git-svn-id: http://wush.net/svn/range/software/public/openbts/trunk@3165 19bc5d8c-e614-43d4-8b26-e1612bc8e597
This commit is contained in:
@@ -63,18 +63,20 @@ static const char* createTMSITable = {
|
||||
|
||||
|
||||
|
||||
TMSITable::TMSITable(const char* wPath)
|
||||
int TMSITable::open(const char* wPath)
|
||||
{
|
||||
int rc = sqlite3_open(wPath,&mDB);
|
||||
if (rc) {
|
||||
LOG(EMERG) << "Cannot open TMSITable database at " << wPath << ": " << sqlite3_errmsg(mDB);
|
||||
sqlite3_close(mDB);
|
||||
mDB = NULL;
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
if (!sqlite3_command(mDB,createTMSITable)) {
|
||||
LOG(EMERG) << "Cannot create TMSI table";
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -53,7 +53,12 @@ class TMSITable {
|
||||
|
||||
public:
|
||||
|
||||
TMSITable(const char*wPath);
|
||||
/**
|
||||
Open the database connection.
|
||||
@param wPath Path to sqlite3 database file.
|
||||
@return 0 if the database was successfully opened and initialized; 1 otherwise
|
||||
*/
|
||||
int open(const char* wPath);
|
||||
|
||||
~TMSITable();
|
||||
|
||||
|
||||
@@ -550,10 +550,10 @@ bool TransactionEntry::terminationRequested()
|
||||
|
||||
|
||||
|
||||
TransactionTable::TransactionTable()
|
||||
void TransactionTable::init()
|
||||
// This assumes the main application uses sdevrandom.
|
||||
:mIDCounter(random())
|
||||
{
|
||||
mIDCounter = random();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -305,10 +305,9 @@ class TransactionTable {
|
||||
public:
|
||||
|
||||
/**
|
||||
Create a transaction table.
|
||||
@param path Path fto sqlite3 database file.
|
||||
Initialize thetransaction table with a random mIDCounter value.
|
||||
*/
|
||||
TransactionTable();
|
||||
void init();
|
||||
|
||||
~TransactionTable();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user