1
0
mirror of https://github.com/aziascreations/BakaShrot.git synced 2026-11-23 20:58:46 +01:00

Stopped long queries, Read is_open() through TLS, Simplified answers and paging

- [server] query_time_limit (20 s by default) stops a client's query
  through SQLite's progress handler: refused with QueryTimedOut (11). A
  client closing while its query runs stops it too.
- The answer timeout in the DLL (BakaShrot_SetAnswerTimeout /
  GetAnswerTimeout, kept across connections), Python (answer_timeout)
  and C# (AnswerTimeoutMs); QueryTimedOut in every binding.
- is_open() reads what's waiting through TLS: a close_notify says
  closed, TLS's own records keep it open, unasked data or a broken
  stream close it.
- The Rust client checks an answer's type in one place (TryFrom per
  packet); Client::wait() pings while waiting (the tool's --follow).
- Pair::from(&Head), heads_after taking a Pair; simpler SyncState
  paging on both ends; the writer's redundant rollback check dropped.
- codes.rs: the bindings' error codes and copied values match Rust's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-21 12:17:28 +01:00
parent a6ade535d0
commit 1bae8ee182
37 changed files with 1064 additions and 264 deletions
+4 -1
View File
@@ -6,7 +6,8 @@
//! What to do about each:
//! - reconnect, then retry: `NotConnected`, `ConnectFailed`,
//! `ConnectionLost`, `ProtocolError` (the connection is closed);
//! - retry later: `NotReady`, `ServerError`;
//! - retry later: `NotReady`, `ServerError`, `QueryTimedOut` (or narrow
//! the query);
//! - fix the configuration: `AuthRejected`, `ServerNotVerified`,
//! `NotAllowed`, `UnknownName`;
//! - update one end: `VersionMismatch`;
@@ -74,6 +75,7 @@ error_codes! {
DataMismatch = 8, "An uploaded attachment that doesn't match its SHA-256: dropped.";
QueryFailed = 9, "The SQL of a query failed (its error in the reason).";
ServerError = 10, "The server couldn't store or read something: its database failed.";
QueryTimedOut = 11, "A query ran past the server's time limit (query_time_limit) and was stopped: narrow it, or retry when the server is less busy.";
// The client's own.
NotConnected = 100, "Not connected: never, or the connection was closed or lost before.";
@@ -140,6 +142,7 @@ mod tests {
(8, "DataMismatch"),
(9, "QueryFailed"),
(10, "ServerError"),
(11, "QueryTimedOut"),
(100, "NotConnected"),
(101, "ConnectFailed"),
(102, "AuthRejected"),
+11
View File
@@ -144,6 +144,17 @@ macro_rules! packets {
Packet::$name(body)
}
}
/// The body of a packet of this type, or the packet back.
impl TryFrom<Packet> for $name {
type Error = Packet;
fn try_from(packet: Packet) -> Result<$name, Packet> {
match packet {
Packet::$name(body) => Ok(body),
other => Err(other),
}
}
}
)*
impl Packet {
@@ -57,6 +57,16 @@ pub struct Head {
pub last_id: u64,
}
impl From<&Head> for Pair {
/// Its pair: to ask the page after it.
fn from(head: &Head) -> Pair {
Pair {
topic: head.topic.clone(),
node: head.node.clone(),
}
}
}
/// An attachment the server lacks, and where to go on from.
///
/// `[topic, node, message_id, next_part]`