mirror of
https://github.com/aziascreations/BakaShrot.git
synced 2026-11-23 20:58:46 +01:00
Fix the server on Linux, and test races it showed
Server: - Storage: #BakaShrot_Storage_SqliteLibrary, the SQLite the server loads: sqlite3.dll on Windows, the system's libsqlite3.so.0 on Linux (PB 5.73's bundled 3.33 has no JSON functions). The query error check and the writer's prepared statements use it too, so a JSON function on a row that isn't JSON is refused on Linux as well, not answered with no rows. - SendPacket: SendNetworkData() returns -1 once the send buffer is full (EAGAIN on Linux), which aborted clients reading big answers. Retried until nothing goes out for #BakaShrot_SendStallTimeout (10 s). Tests, timing they relied on: - Attachments, BigMessages: link failures before the first link are expected, Linux refuses at once where Windows retries for ~1 s. - Restart: a pusher whose server is killed between two pushes sees 100 (NotConnected), during one 104 (ConnectionLost): both accepted. - Retention: deletions counted over every retention check, a batch can be split over two. - AttachmentEdges: waits for B's corrupted attachment to be dropped, A sends it again at every check-in. All tests pass on Linux with PB 6.41 (asm and C backends). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RwFeVQCBfcPDfAPqX8z2TF
This commit is contained in:
@@ -19,9 +19,10 @@
|
||||
; that were waiting find theirs done. The busier, the bigger the groups.
|
||||
; - Prepared statements, kept for as long as the writer is open, through
|
||||
; SQLite's own API: PureBasic prepares a statement again on every call.
|
||||
; Same sqlite3.dll as PureBasic's (DatabaseID() is its sqlite3 handle).
|
||||
; Elsewhere than Windows, PureBasic's own SQLite is linked in, so its
|
||||
; functions are used instead (slower, same behaviour).
|
||||
; Same #BakaShrot_Storage_SqliteLibrary as PureBasic's (DatabaseID() is
|
||||
; its sqlite3 handle). Without #BakaShrot_Storage_ExternalSqlite (see
|
||||
; Storage.pbi), PureBasic's own SQLite is linked in, so its functions
|
||||
; are used instead (slower, same behaviour).
|
||||
; - The next message id of every topic/node id kept in memory, instead of
|
||||
; a MAX(message_id) on every push. Read from the database the first time
|
||||
; a pair is pushed to (node_heads, which deleting messages leaves as is:
|
||||
@@ -62,11 +63,7 @@
|
||||
#BakaShrot_Storage_WalSizeLimit = 67108864
|
||||
|
||||
|
||||
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
|
||||
#BakaShrot_Storage_RawSqlite = #True
|
||||
CompilerElse
|
||||
#BakaShrot_Storage_RawSqlite = #False
|
||||
CompilerEndIf
|
||||
#BakaShrot_Storage_RawSqlite = #BakaShrot_Storage_ExternalSqlite
|
||||
|
||||
#BakaShrot_Sqlite_Done = 101
|
||||
#BakaShrot_Sqlite_Row = 100
|
||||
@@ -387,7 +384,7 @@ CompilerIf #BakaShrot_Storage_RawSqlite
|
||||
ProcedureReturn #True
|
||||
EndIf
|
||||
; The one PureBasic's SQLite driver already loaded.
|
||||
\Library = OpenLibrary(#PB_Any, "sqlite3.dll")
|
||||
\Library = OpenLibrary(#PB_Any, #BakaShrot_Storage_SqliteLibrary)
|
||||
If Not \Library
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
@@ -527,7 +524,7 @@ Procedure.i OpenStorageWriter(DatabasePath.s, *Error.String)
|
||||
|
||||
CompilerIf #BakaShrot_Storage_RawSqlite
|
||||
If Not BakaShrot_Writer_LoadSqlite()
|
||||
*Error\s = "sqlite3.dll doesn't have the functions needed"
|
||||
*Error\s = #BakaShrot_Storage_SqliteLibrary + " doesn't have the functions needed"
|
||||
BakaShrot_Writer_Release()
|
||||
UnlockMutex(BakaShrot_Storage_WriteMutex)
|
||||
ProcedureReturn #False
|
||||
|
||||
Reference in New Issue
Block a user