1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
From c159bc0d6be03ce566a5a0e144a503d174aee91f Mon Sep 17 00:00:00 2001
From: Benedikt Peetz <benedikt.peetz@b-peetz.de>
Date: Mon, 24 Aug 2026 21:18:39 +0200
Subject: [PATCH 06/10] history/turtle: Don't block at startup, and wait until
history is loaded
---
src/history/turtle.rs | 49 +++----------------------------------------
1 file changed, 3 insertions(+), 46 deletions(-)
diff --git a/src/history/turtle.rs b/src/history/turtle.rs
index 862b7346b..a1009a162 100644
--- a/src/history/turtle.rs
+++ b/src/history/turtle.rs
@@ -31,16 +31,8 @@ struct HistoryDbInner {
impl HistoryDbInner {
fn loaded_history(&mut self) -> &[History] {
- let should_wait = if self.loaded_history.is_empty() {
- // We are probably running this the first time.
- // Make sure, that we actually load something.
- true
- } else {
- false
- };
-
- if NEW_LOADED_HISTORY_AVAILABLE.load(Ordering::Relaxed) || should_wait {
- if let Some(pre_loaded_history) = self.handler.load_history_resp(should_wait) {
+ if NEW_LOADED_HISTORY_AVAILABLE.load(Ordering::Relaxed) {
+ if let Some(pre_loaded_history) = self.handler.load_history_resp() {
self.loaded_history = pre_loaded_history;
// HACK(@bpeetz): For some reason, the returned history is reversed.
@@ -237,8 +229,6 @@ enum HandleHistoryCmd {
}
static HANDLER_IS_SHUTTING_DOWN: AtomicBool = AtomicBool::new(false);
-static LOAD_HISTORY_THREAD: RwLock<Option<Thread>> = RwLock::new(None);
-static LOAD_HISTORY_WAITING: AtomicBool = AtomicBool::new(false);
static NEW_LOADED_HISTORY_AVAILABLE: AtomicBool = AtomicBool::new(false);
impl Handler {
@@ -325,16 +315,6 @@ fn start(daemon_socket: String) -> Self {
let mut output = loaded_history_return.write().expect("not poisioned");
(*output) = Some(loaded_history);
NEW_LOADED_HISTORY_AVAILABLE.store(true, Ordering::Relaxed);
-
- if LOAD_HISTORY_WAITING.load(Ordering::Relaxed) {
- let read = LOAD_HISTORY_THREAD.read().expect("not poisioned");
- let t = read
- .as_ref()
- .expect("is some, as a thread is marked as waiting");
-
- LOAD_HISTORY_WAITING.store(false, Ordering::Relaxed);
- t.unpark();
- }
}
}
}
@@ -364,7 +344,7 @@ fn stop(&mut self) {
flog!(history, "History db shutdown completed.");
}
- fn load_history_resp(&self, should_wait: bool) -> Option<Vec<History>> {
+ fn load_history_resp(&self) -> Option<Vec<History>> {
let mut output = None;
let rx = &self.returned_loaded_history;
@@ -372,29 +352,6 @@ fn load_history_resp(&self, should_wait: bool) -> Option<Vec<History>> {
read.clone_into(&mut output);
}
- if should_wait && output.is_none() {
- {
- {
- let me = thread::current();
- let mut write = LOAD_HISTORY_THREAD.write().expect("not poisioned");
- (*write) = Some(me);
- }
-
- LOAD_HISTORY_WAITING.store(true, Ordering::Relaxed);
- while LOAD_HISTORY_WAITING.load(Ordering::Relaxed) {
- thread::park();
- }
-
- {
- let mut write = LOAD_HISTORY_THREAD.write().expect("not poisioned");
- (*write) = None;
- }
- }
-
- let read = rx.read().expect("not poisioned");
- read.clone_into(&mut output);
- }
-
output
}
--
2.55.0
|