aboutsummaryrefslogtreecommitdiff
path: root/models/issue_comment.go
diff options
context:
space:
mode:
authorstroucki <stroucki@andrew.cmu.edu>2016-12-21 04:11:07 -0500
committer无闻 <u@gogs.io>2016-12-21 04:11:07 -0500
commite9f6a4307372b8e82518b10c89a9a7d649153d73 (patch)
treeae297d7914a18fbd3b66eb3fa86a86061c0e21dd /models/issue_comment.go
parent67380cf47b6dfd6ff9999acc73dd7da8f620948f (diff)
Fix database write context interleaving bug (#3822)
* UpdateIssueUsersByMentions was calling database write operations while a transaction session was in progress. MailParticipants was failing silently because of the SQLITE_LOCKED error. Make sure failures in MailParticipants enter the log, and pass on the transaction context. issue: let caller pass in database context, and use it issue_comment: obtain database context to pass to UpdateIssueMentions issue_comment: log any error from call to MailParticipants issue_mail: pass on database context to UpdateIssueMentions * issue: forgot debug statement
Diffstat (limited to 'models/issue_comment.go')
-rw-r--r--models/issue_comment.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/models/issue_comment.go b/models/issue_comment.go
index 091bfc3b..3f81889c 100644
--- a/models/issue_comment.go
+++ b/models/issue_comment.go
@@ -162,9 +162,9 @@ func (c *Comment) EventTag() string {
// MailParticipants sends new comment emails to repository watchers
// and mentioned people.
-func (cmt *Comment) MailParticipants(opType ActionType, issue *Issue) (err error) {
+func (cmt *Comment) MailParticipants(e Engine, opType ActionType, issue *Issue) (err error) {
mentions := markdown.FindAllMentions(cmt.Content)
- if err = UpdateIssueMentions(cmt.IssueID, mentions); err != nil {
+ if err = UpdateIssueMentions(e, cmt.IssueID, mentions); err != nil {
return fmt.Errorf("UpdateIssueMentions [%d]: %v", cmt.IssueID, err)
}
@@ -278,7 +278,9 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
if err = notifyWatchers(e, act); err != nil {
log.Error(4, "notifyWatchers: %v", err)
}
- comment.MailParticipants(act.OpType, opts.Issue)
+ if err = comment.MailParticipants(e, act.OpType, opts.Issue); err != nil {
+ log.Error(4, "MailParticipants: %v", err)
+ }
}
return comment, comment.loadAttributes(e)