mesh-sdk: the wait for Serve is driven by the test, no real timers; a Placement domain is refused (issue 1966)
Claude-Session: https://claude.ai/code/session_01NcbgfFSnn24M3GcqttoU7i
This commit is contained in:
+9
-3
@@ -446,6 +446,12 @@ func ServeOn(name string, tools []Tool, in io.Reader, out io.Writer) error {
|
||||
// process that never serves is refused, after this long.
|
||||
var serveWait = 30 * time.Second
|
||||
|
||||
// serveTimer starts that wait: its channel fires when the wait ends, and stop releases it. A test replaces it.
|
||||
var serveTimer = func() (<-chan time.Time, func()) {
|
||||
t := time.NewTimer(serveWait)
|
||||
return t.C, func() { t.Stop() }
|
||||
}
|
||||
|
||||
// awaitChannel is the runtime's channel, waiting up to serveWait for Serve to set it.
|
||||
func awaitChannel() *channel {
|
||||
currentMu.Lock()
|
||||
@@ -454,11 +460,11 @@ func awaitChannel() *channel {
|
||||
if c != nil {
|
||||
return c
|
||||
}
|
||||
t := time.NewTimer(serveWait)
|
||||
defer t.Stop()
|
||||
expired, stop := serveTimer()
|
||||
defer stop()
|
||||
select {
|
||||
case <-ready:
|
||||
case <-t.C:
|
||||
case <-expired:
|
||||
return nil
|
||||
}
|
||||
currentMu.Lock()
|
||||
|
||||
Reference in New Issue
Block a user