Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safely reopen gravity database #847

Merged
merged 1 commit into from Jul 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/database/gravity-db.c
Expand Up @@ -54,6 +54,14 @@ void gravityDB_forked(void)
gravityDB_open();
}

void gravityDB_reopen(void)
{
lock_shm();
gravityDB_close();
gravityDB_open();
unlock_shm();
}

// Open gravity database
bool gravityDB_open(void)
{
Expand Down
1 change: 1 addition & 0 deletions src/database/gravity-db.h
Expand Up @@ -19,6 +19,7 @@
enum gravity_tables { GRAVITY_TABLE, EXACT_BLACKLIST_TABLE, EXACT_WHITELIST_TABLE, REGEX_BLACKLIST_TABLE, REGEX_WHITELIST_TABLE, UNKNOWN_TABLE } __attribute__ ((packed));

void gravityDB_forked(void);
void gravityDB_reopen(void);
bool gravityDB_open(void);
bool gravityDB_prepare_client_statements(const int clientID, clientsData* client);
void gravityDB_close(void);
Expand Down
3 changes: 1 addition & 2 deletions src/datastructure.c
Expand Up @@ -378,8 +378,7 @@ void FTL_reload_all_domainlists(void)
flush_message_table();

// (Re-)open gravity database connection
gravityDB_close();
gravityDB_open();
gravityDB_reopen();

// Reset number of blocked domains
counters->gravity = gravityDB_count(GRAVITY_TABLE);
Expand Down