From 760b53e2d164529eefc81c6dde43a0b431932d7f Mon Sep 17 00:00:00 2001 From: "Jonathan A. Sternberg" Date: Mon, 7 Oct 2024 11:27:10 -0500 Subject: [PATCH] create outgoing requests to its own function Signed-off-by: Jonathan A. Sternberg --- solver/edge.go | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/solver/edge.go b/solver/edge.go index 35660a88954bb..6910187f0453e 100644 --- a/solver/edge.go +++ b/solver/edge.go @@ -779,27 +779,7 @@ func (e *edge) createInputRequests(desiredState edgeStatusType, f *pipeFactory, // outgoing request is needed if dep.state < desiredStateDep { - addNew := true - if dep.req != nil && !dep.req.Status().Completed { - if dep.req.Request().desiredState != desiredStateDep { - debugSchedulerCancelInputRequest(e, dep, desiredStateDep) - dep.req.Cancel() - } else { - debugSchedulerSkipInputRequestBasedOnExistingRequest(e, dep, desiredStateDep) - addNew = false - } - } - if addNew { - debugSchedulerAddInputRequest(e, dep, desiredStateDep) - req := f.NewInputRequest(e.edge.Vertex.Inputs()[int(dep.index)], &edgeRequest{ - currentState: dep.edgeState, - desiredState: desiredStateDep, - currentKeys: len(dep.keys), - }) - e.depRequests[req] = dep - dep.req = req - addedNew = true - } + addedNew = e.createOutgoingRequest(dep, desiredStateDep, f) || addedNew } else { debugSchedulerSkipInputRequestBasedOnDepState(e, dep, desiredStateDep) } @@ -871,6 +851,27 @@ func (e *edge) desiredStateDep(dep *dep, desiredState edgeStatusType, force bool return dep.state } +func (e *edge) createOutgoingRequest(dep *dep, desiredStateDep edgeStatusType, f *pipeFactory) (addedNew bool) { + if dep.req != nil && !dep.req.Status().Completed { + if dep.req.Request().desiredState == desiredStateDep { + debugSchedulerSkipInputRequestBasedOnExistingRequest(e, dep, desiredStateDep) + return false + } + debugSchedulerCancelInputRequest(e, dep, desiredStateDep) + dep.req.Cancel() + } + + debugSchedulerAddInputRequest(e, dep, desiredStateDep) + req := f.NewInputRequest(e.edge.Vertex.Inputs()[int(dep.index)], &edgeRequest{ + currentState: dep.edgeState, + desiredState: desiredStateDep, + currentKeys: len(dep.keys), + }) + e.depRequests[req] = dep + dep.req = req + return true +} + // execIfPossible creates a request for getting the edge result if there is // enough state func (e *edge) execIfPossible(f *pipeFactory) bool {