From dc945b5b786bef055fa4b13f451157ba31ec52a9 Mon Sep 17 00:00:00 2001 From: Javier Sagredo Date: Tue, 16 Jun 2026 23:49:12 +0200 Subject: [PATCH] Proper backtracking on interrupted socket/http listeners --- src/machine/system_calls.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/machine/system_calls.rs b/src/machine/system_calls.rs index 0e36d1ad..d83f6bd6 100644 --- a/src/machine/system_calls.rs +++ b/src/machine/system_calls.rs @@ -4737,8 +4737,6 @@ impl Machine { ) { Ok(interruption) => { if interruption { - self.machine_st.throw_interrupt_exception(); - self.machine_st.backtrack(); // We have extracted control over the Tokio runtime to the calling context for enabling library use case // (see https://github.com/mthom/scryer-prolog/pull/1880) // So we only have access to a runtime handle in here and can't shut it down. @@ -4855,7 +4853,9 @@ impl Machine { } Err(std::sync::mpsc::RecvTimeoutError::Timeout) => { if self.interrupt_occured() { - break; + let err = self.machine_st.interrupt_error(); + let src = functor_stub(atom!("repl"), 0); + return Err(self.machine_st.error_form(err, src)); } } Err(_) => { @@ -7218,7 +7218,9 @@ impl Machine { Err(ref e) if e.kind() == ErrorKind::WouldBlock => { std::thread::sleep(std::time::Duration::from_millis(200)); if self.interrupt_occured() { - break; + let err = self.machine_st.interrupt_error(); + let src = functor_stub(atom!("repl"), 0); + return Err(self.machine_st.error_form(err, src)); } } Err(_) => { -- 2.54.0