aboutsummaryrefslogtreecommitdiffstats
path: root/services/pull/check.go
diff options
context:
space:
mode:
Diffstat (limited to 'services/pull/check.go')
-rw-r--r--services/pull/check.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/services/pull/check.go b/services/pull/check.go
index 7d93ff7a8a..ce212f7d83 100644
--- a/services/pull/check.go
+++ b/services/pull/check.go
@@ -21,6 +21,7 @@ import (
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/gitrepo"
+ "code.gitea.io/gitea/modules/globallock"
"code.gitea.io/gitea/modules/graceful"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/process"
@@ -334,9 +335,15 @@ func handler(items ...string) []string {
}
func testPR(id int64) {
- pullWorkingPool.CheckIn(fmt.Sprint(id))
- defer pullWorkingPool.CheckOut(fmt.Sprint(id))
- ctx, _, finished := process.GetManager().AddContext(graceful.GetManager().HammerContext(), fmt.Sprintf("Test PR[%d] from patch checking queue", id))
+ ctx := graceful.GetManager().HammerContext()
+ releaser, err := globallock.Lock(ctx, getPullWorkingLockKey(id))
+ if err != nil {
+ log.Error("lock.Lock(): %v", err)
+ return
+ }
+ defer releaser()
+
+ ctx, _, finished := process.GetManager().AddContext(ctx, fmt.Sprintf("Test PR[%d] from patch checking queue", id))
defer finished()
pr, err := issues_model.GetPullRequestByID(ctx, id)