diff --git a/dnsmasq_interface.c b/dnsmasq_interface.c index be18433f..f2c72fbd 100644 --- a/dnsmasq_interface.c +++ b/dnsmasq_interface.c @@ -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) diff --git a/gravity.c b/gravity.c index e91d3684..76300329 100644 --- a/gravity.c +++ b/gravity.c @@ -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; }