@@ -445,7 +445,7 @@ void SQLiteBatch::Close()
445
445
try {
446
446
m_database.Open ();
447
447
// If TxnAbort failed and we refreshed the connection, the semaphore was not released, so release it here to avoid deadlocks on future writes.
448
- m_database.m_write_semaphore .post ();
448
+ m_database.m_write_semaphore .release ();
449
449
} catch (const std::runtime_error&) {
450
450
// If open fails, cleanup this object and rethrow the exception
451
451
m_database.Close ();
@@ -498,7 +498,7 @@ bool SQLiteBatch::WriteKey(DataStream&& key, DataStream&& value, bool overwrite)
498
498
if (!BindBlobToStatement (stmt, 2 , value, " value" )) return false ;
499
499
500
500
// Acquire semaphore if not previously acquired when creating a transaction.
501
- if (!m_txn) m_database.m_write_semaphore .wait ();
501
+ if (!m_txn) m_database.m_write_semaphore .acquire ();
502
502
503
503
// Execute
504
504
int res = sqlite3_step (stmt);
@@ -508,7 +508,7 @@ bool SQLiteBatch::WriteKey(DataStream&& key, DataStream&& value, bool overwrite)
508
508
LogPrintf (" %s: Unable to execute statement: %s\n " , __func__, sqlite3_errstr (res));
509
509
}
510
510
511
- if (!m_txn) m_database.m_write_semaphore .post ();
511
+ if (!m_txn) m_database.m_write_semaphore .release ();
512
512
513
513
return res == SQLITE_DONE;
514
514
}
@@ -522,7 +522,7 @@ bool SQLiteBatch::ExecStatement(sqlite3_stmt* stmt, std::span<const std::byte> b
522
522
if (!BindBlobToStatement (stmt, 1 , blob, " key" )) return false ;
523
523
524
524
// Acquire semaphore if not previously acquired when creating a transaction.
525
- if (!m_txn) m_database.m_write_semaphore .wait ();
525
+ if (!m_txn) m_database.m_write_semaphore .acquire ();
526
526
527
527
// Execute
528
528
int res = sqlite3_step (stmt);
@@ -532,7 +532,7 @@ bool SQLiteBatch::ExecStatement(sqlite3_stmt* stmt, std::span<const std::byte> b
532
532
LogPrintf (" %s: Unable to execute statement: %s\n " , __func__, sqlite3_errstr (res));
533
533
}
534
534
535
- if (!m_txn) m_database.m_write_semaphore .post ();
535
+ if (!m_txn) m_database.m_write_semaphore .release ();
536
536
537
537
return res == SQLITE_DONE;
538
538
}
@@ -651,12 +651,12 @@ std::unique_ptr<DatabaseCursor> SQLiteBatch::GetNewPrefixCursor(std::span<const
651
651
bool SQLiteBatch::TxnBegin ()
652
652
{
653
653
if (!m_database.m_db || m_txn) return false ;
654
- m_database.m_write_semaphore .wait ();
654
+ m_database.m_write_semaphore .acquire ();
655
655
Assert (!m_database.HasActiveTxn ());
656
656
int res = Assert (m_exec_handler)->Exec (m_database, " BEGIN TRANSACTION" );
657
657
if (res != SQLITE_OK) {
658
658
LogPrintf (" SQLiteBatch: Failed to begin the transaction\n " );
659
- m_database.m_write_semaphore .post ();
659
+ m_database.m_write_semaphore .release ();
660
660
} else {
661
661
m_txn = true ;
662
662
}
@@ -672,7 +672,7 @@ bool SQLiteBatch::TxnCommit()
672
672
LogPrintf (" SQLiteBatch: Failed to commit the transaction\n " );
673
673
} else {
674
674
m_txn = false ;
675
- m_database.m_write_semaphore .post ();
675
+ m_database.m_write_semaphore .release ();
676
676
}
677
677
return res == SQLITE_OK;
678
678
}
@@ -686,7 +686,7 @@ bool SQLiteBatch::TxnAbort()
686
686
LogPrintf (" SQLiteBatch: Failed to abort the transaction\n " );
687
687
} else {
688
688
m_txn = false ;
689
- m_database.m_write_semaphore .post ();
689
+ m_database.m_write_semaphore .release ();
690
690
}
691
691
return res == SQLITE_OK;
692
692
}
0 commit comments