Review comments

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2019-04-27 15:45:13 +02:00
parent b2e19ff469
commit 23c92d45de
2 changed files with 6 additions and 14 deletions

View File

@@ -1328,10 +1328,10 @@ static void block_single_domain_regex(const char *domain)
if(config.debug & DEBUG_QUERIES) logg("Added %s to cache", domain);
}
// Import a specified table form the gravity database and
// Import a specified table from the gravity database and
// add the read domains to the cache using the currently
// selected blocking mode. This function is used to import
// both, the blacklist as well as the gravity blocking domains
// both the blacklist and the gravity blocking domains
static int FTL_table_import(const char *tablename, const unsigned char list, const unsigned int index,
struct all_addr addr4, struct all_addr addr6, bool has_IPv4, bool has_IPv6,
int cache_size, struct crec **rhash, int hashsz)

View File

@@ -50,18 +50,12 @@ static bool gravityDB_open(void)
return true;
}
// Close gravity database handle
static void gravityDB_close(void)
{
sqlite3_close(gravitydb);
}
// Prepare a SQLite3 statement which can be used by
// gravityDB_getDomain() to get blocking domains from
// a table which is specified when calling this function
bool gravityDB_getTable(const unsigned char list)
{
// Open gravity database, fail is not possible
// Open gravity database
// Note: This might fail when the database has
// not yet been created by gravity
if(!gravityDB_open())
@@ -125,8 +119,7 @@ inline const char* gravityDB_getDomain(void)
if(rc != SQLITE_DONE)
{
logg("gravityDB_getDomain() - SQL error step (%i): %s", rc, sqlite3_errmsg(gravitydb));
sqlite3_finalize(stmt);
sqlite3_close(gravitydb);
gravityDB_finalizeTable();
return NULL;
}
@@ -142,7 +135,7 @@ void gravityDB_finalizeTable(void)
sqlite3_finalize(stmt);
// Close database handle
gravityDB_close();
sqlite3_close(gravitydb);
}
// Get number of domains in a specified table of the gravity database
@@ -197,8 +190,7 @@ int gravityDB_count(const unsigned char list)
const int result = sqlite3_column_int(stmt, 0);
// Finalize statement and close database handle
sqlite3_finalize(stmt);
gravityDB_close();
gravityDB_finalizeTable();
return result;
}