mirror of
https://github.com/isar/rusqlite.git
synced 2025-04-10 01:07:45 +08:00
Merge pull request #1548 from gwenn/not_owned_interrupt_lock
Prevent interrupt from non-owned connection
This commit is contained in:
commit
c67b7d6b20
@ -46,7 +46,7 @@ impl InnerConnection {
|
|||||||
pub unsafe fn new(db: *mut ffi::sqlite3, owned: bool) -> InnerConnection {
|
pub unsafe fn new(db: *mut ffi::sqlite3, owned: bool) -> InnerConnection {
|
||||||
InnerConnection {
|
InnerConnection {
|
||||||
db,
|
db,
|
||||||
interrupt_lock: Arc::new(Mutex::new(db)),
|
interrupt_lock: Arc::new(Mutex::new(if owned { db } else { ptr::null_mut() })),
|
||||||
#[cfg(feature = "hooks")]
|
#[cfg(feature = "hooks")]
|
||||||
free_commit_hook: None,
|
free_commit_hook: None,
|
||||||
#[cfg(feature = "hooks")]
|
#[cfg(feature = "hooks")]
|
||||||
@ -155,7 +155,7 @@ impl InnerConnection {
|
|||||||
self.remove_preupdate_hook();
|
self.remove_preupdate_hook();
|
||||||
let mut shared_handle = self.interrupt_lock.lock().unwrap();
|
let mut shared_handle = self.interrupt_lock.lock().unwrap();
|
||||||
assert!(
|
assert!(
|
||||||
!shared_handle.is_null(),
|
!self.owned || !shared_handle.is_null(),
|
||||||
"Bug: Somehow interrupt_lock was cleared before the DB was closed"
|
"Bug: Somehow interrupt_lock was cleared before the DB was closed"
|
||||||
);
|
);
|
||||||
if !self.owned {
|
if !self.owned {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user