summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim "BKC" Carlbäcker <kim.carlbacker@gmail.com>2017-05-08 10:02:44 +0200
committerGitHub <noreply@github.com>2017-05-08 10:02:44 +0200
commita85c5ab9ff60dab58b2bf713479460caac8e9567 (patch)
treec9fb4d0f22f7c6bffd4df3667752c6f37a6e5d8c
parent2bb8b3a56219f3fcba7c77c7a8fc10769b8c11bd (diff)
parent36f02c0c329760c556dfd143c3e9def5416c9640 (diff)
downloadgitea-a85c5ab9ff60dab58b2bf713479460caac8e9567.tar.gz
gitea-a85c5ab9ff60dab58b2bf713479460caac8e9567.zip
fix potential sqlite lock #1680
-rw-r--r--models/webhook.go16
1 files changed, 7 insertions, 9 deletions
diff --git a/models/webhook.go b/models/webhook.go
index 8cd2b7dd43..3fb1e57e78 100644
--- a/models/webhook.go
+++ b/models/webhook.go
@@ -612,18 +612,16 @@ func (t *HookTask) deliver() {
// TODO: shoot more hooks at same time.
func DeliverHooks() {
tasks := make([]*HookTask, 0, 10)
- x.
- Where("is_delivered=?", false).
- Iterate(new(HookTask),
- func(idx int, bean interface{}) error {
- t := bean.(*HookTask)
- t.deliver()
- tasks = append(tasks, t)
- return nil
- })
+ err := x.Where("is_delivered=?", false).Find(&tasks)
+ if err != nil {
+ log.Error(4, "DeliverHooks: %v", err)
+ return
+ }
// Update hook task status.
for _, t := range tasks {
+ t.deliver()
+
if err := UpdateHookTask(t); err != nil {
log.Error(4, "UpdateHookTask [%d]: %v", t.ID, err)
}