Terminate watcher if database changes (#20)
* Terminate watcher if database changes
* Format
* Update watcher.cpp
* Revert "Format"
This reverts commit 72d82f4bce.
This commit is contained in:
@@ -26,6 +26,7 @@ private:
|
||||
std::condition_variable cv;
|
||||
std::atomic<bool> should_run;
|
||||
HttpServer &server;
|
||||
DatabaseInstance *watched_database;
|
||||
};
|
||||
} // namespace ui
|
||||
} // namespace duckdb
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
namespace duckdb {
|
||||
namespace ui {
|
||||
|
||||
Watcher::Watcher(HttpServer &_server) : should_run(false), server(_server) {}
|
||||
Watcher::Watcher(HttpServer &_server)
|
||||
: should_run(false), server(_server), watched_database(nullptr) {}
|
||||
|
||||
bool WasCatalogUpdated(DatabaseInstance &db, Connection &connection,
|
||||
CatalogState &last_state) {
|
||||
@@ -62,6 +63,12 @@ void Watcher::Watch() {
|
||||
break; // DB went away, nothing to watch
|
||||
}
|
||||
|
||||
if (watched_database == nullptr) {
|
||||
watched_database = db.get();
|
||||
} else if (watched_database != db.get()) {
|
||||
break; // DB changed, stop watching, will be restarted
|
||||
}
|
||||
|
||||
duckdb::Connection con{*db};
|
||||
auto polling_interval = GetPollingInterval(*con.context);
|
||||
if (polling_interval == 0) {
|
||||
|
||||
Reference in New Issue
Block a user