Skip to content

Commit

Permalink
fix libsql_close
Browse files Browse the repository at this point in the history
  • Loading branch information
rflopezm committed Dec 20, 2024
1 parent b50ab45 commit 6a8022d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
4 changes: 0 additions & 4 deletions cpp/DBHostObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,11 +808,7 @@ void DBHostObject::invalidate() {
invalidated = true;
_thread_pool->restartPool();
#ifdef OP_SQLITE_USE_LIBSQL
if (db.db != nullptr and db.c != nullptr) {
opsqlite_libsql_close(db);
db.db = nullptr;
db.c = nullptr;
}
#else
if (db != nullptr) {
opsqlite_close(db);
Expand Down
6 changes: 4 additions & 2 deletions cpp/libsql/bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,14 @@ DB opsqlite_libsql_open_remote(std::string const &url,
return {.db = db, .c = c};
}

void opsqlite_libsql_close(DB const &db) {
void opsqlite_libsql_close(DB &db) {
if (db.c != nullptr) {
libsql_disconnect(db.c);
db.c = nullptr;
}
if (db.db != nullptr) {
libsql_close(db.db);
db.db = nullptr;
}
}

Expand Down Expand Up @@ -161,7 +163,7 @@ void opsqlite_libsql_sync(DB const &db) {

}

void opsqlite_libsql_remove(DB const &db, std::string const &name,
void opsqlite_libsql_remove(DB &db, std::string const &name,
std::string const &path) {
opsqlite_libsql_close(db);

Expand Down
4 changes: 2 additions & 2 deletions cpp/libsql/bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ DB opsqlite_libsql_open_sync(std::string const &name,
std::string const &auth_token,
int sync_interval);

void opsqlite_libsql_close(DB const &db);
void opsqlite_libsql_close(DB &db);

void opsqlite_libsql_remove(DB const &db, std::string const &name,
void opsqlite_libsql_remove(DB &db, std::string const &name,
std::string const &path);

void opsqlite_libsql_attach(DB const &db,
Expand Down

0 comments on commit 6a8022d

Please sign in to comment.