Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
lock stealing
Browse files Browse the repository at this point in the history
  • Loading branch information
MarinPostma committed Sep 22, 2023
1 parent f214ad4 commit 6a99215
Show file tree
Hide file tree
Showing 8 changed files with 521 additions and 164 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ members = [
]

[workspace.dependencies]
rusqlite = { version = "0.29.0", git = "https://github.com/psarna/rusqlite", rev = "2e28bca6", default-features = false, features = [
rusqlite = { version = "0.29.0", git = "https://github.com/tursodatabase/rusqlite.git", rev = "a72d529", default-features = false, features = [
"buildtime_bindgen",
"bundled-libsql-wasm-experimental",
"column_decltype",
"load_extension"
"load_extension",
"modern_sqlite"
] }

# Config for 'cargo dist'
Expand Down
15 changes: 10 additions & 5 deletions sqld-libsql-bindings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::{ffi::CString, ops::Deref, time::Duration};

pub use crate::wal_hook::WalMethodsHook;
pub use once_cell::sync::Lazy;
use rusqlite::ffi::sqlite3;
use wal_hook::TransparentMethods;

use self::{
Expand Down Expand Up @@ -50,7 +51,6 @@ impl Connection<TransparentMethods> {
}

impl<W: WalHook> Connection<W> {

/// Opens a database with the regular wal methods in the directory pointed to by path
pub fn open(
path: impl AsRef<std::path::Path>,
Expand Down Expand Up @@ -103,9 +103,14 @@ impl<W: WalHook> Connection<W> {
let conn = unsafe { rusqlite::Connection::from_handle_owned(db)? };
conn.busy_timeout(Duration::from_millis(5000))?;

Ok(Connection {
conn,
_ctx,
})
Ok(Connection { conn, _ctx })
}

/// Returns the raw sqlite handle
///
/// # Safety
/// The caller is responsible for the returned pointer.
pub unsafe fn handle(&mut self) -> *mut sqlite3 {
self.conn.handle()
}
}
Loading

0 comments on commit 6a99215

Please sign in to comment.