From cc249d98a5e29b92bb91a73d9c3e0d61351aede8 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 6 Jun 2021 10:34:46 +0800 Subject: [PATCH] Remove unnecessary goroutine --- services/pull/check.go | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/services/pull/check.go b/services/pull/check.go index 3ec76de5e874..9db1654cfbc0 100644 --- a/services/pull/check.go +++ b/services/pull/check.go @@ -28,21 +28,19 @@ var prQueue queue.UniqueQueue // AddToTaskQueue adds itself to pull request test task queue. func AddToTaskQueue(pr *models.PullRequest) { - go func() { - err := prQueue.PushFunc(strconv.FormatInt(pr.ID, 10), func() error { - pr.Status = models.PullRequestStatusChecking - err := pr.UpdateColsIfNotMerged("status") - if err != nil { - log.Error("AddToTaskQueue.UpdateCols[%d].(add to queue): %v", pr.ID, err) - } else { - log.Trace("Adding PR ID: %d to the test pull requests queue", pr.ID) - } - return err - }) - if err != nil && err != queue.ErrAlreadyInQueue { - log.Error("Error adding prID %d to the test pull requests queue: %v", pr.ID, err) + err := prQueue.PushFunc(strconv.FormatInt(pr.ID, 10), func() error { + pr.Status = models.PullRequestStatusChecking + err := pr.UpdateColsIfNotMerged("status") + if err != nil { + log.Error("AddToTaskQueue.UpdateCols[%d].(add to queue): %v", pr.ID, err) + } else { + log.Trace("Adding PR ID: %d to the test pull requests queue", pr.ID) } - }() + return err + }) + if err != nil && err != queue.ErrAlreadyInQueue { + log.Error("Error adding prID %d to the test pull requests queue: %v", pr.ID, err) + } } // checkAndUpdateStatus checks if pull request is possible to leaving checking status,