Fix solver startup race condition with Notify

The HTTP-01 and TLS-ALPN-01 solvers used tokio::sync::Notify to signal
that the server task had started. If the spawned task called
notify_waiters() before the caller registered with notified(), the
notification was lost and the solver would hang indefinitely.

Fix by creating the Notified future before spawning the task.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Roman Kivalin
2026-04-17 21:28:36 +02:00
co-authored by Claude Opus 4.6
parent 2e2cabe19d
commit ff83ce0ca1
4 changed files with 11 additions and 3 deletions
+2
View File
@@ -6,6 +6,8 @@
### Fixes
- Fix HTTP-01 and TLS-ALPN-01 solvers sometimes hanging on startup due to a `Notify` race condition
### Changes
## 0.7.0 (2026-04-17)
+1 -1
View File
@@ -1,6 +1,6 @@
certforge (0.8.0-1) unstable; urgency=low
* No changes
* Fix HTTP-01 and TLS-ALPN-01 solvers hanging on startup
-- Roman Kivalin <roman@shl.dev> Thu, 17 Apr 2026 00:00:00 +0000
+4 -1
View File
@@ -61,6 +61,9 @@ impl Http01StandaloneSolver {
let tokens = self.tokens.clone();
let started = self.server_started.clone();
// Register the listener before spawning so we don't miss the notification
let notified = self.server_started.notified();
let handle = tokio::spawn(async move {
started.notify_waiters();
// Spawn an accept loop for each bound listener
@@ -93,7 +96,7 @@ impl Http01StandaloneSolver {
}
});
self.server_started.notified().await;
notified.await;
Ok::<_, Error>(handle)
}).await;
+4 -1
View File
@@ -77,6 +77,9 @@ impl TlsAlpn01Solver {
let acceptor = TlsAcceptor::from(tls_config);
// Register the listener before spawning so we don't miss the notification
let notified = self.server_started.notified();
let handle = tokio::spawn(async move {
started.notify_waiters();
let mut handles = Vec::new();
@@ -99,7 +102,7 @@ impl TlsAlpn01Solver {
}
});
self.server_started.notified().await;
notified.await;
Ok::<_, Error>(handle)
}).await;