Skip to content

Commit

Permalink
sql: fix connection leak
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeneas Rekkas (arekkas) committed Jan 22, 2017
1 parent 0633811 commit 511d561
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions manager_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ func (s *SQLManager) Create(policy Policy) (err error) {
if tx, err := s.db.Begin(); err != nil {
return errors.WithStack(err)
} else if _, err = tx.Exec(s.db.Rebind("INSERT INTO ladon_policy (id, description, effect, conditions) VALUES (?, ?, ?, ?)"), policy.GetID(), policy.GetDescription(), policy.GetEffect(), conditions); err != nil {
if err := tx.Rollback(); err != nil {
return errors.WithStack(err)
}
return errors.WithStack(err)
} else if err = createLinkSQL(s.db, tx, "ladon_policy_subject", policy, policy.GetSubjects()); err != nil {
return err
Expand Down

0 comments on commit 511d561

Please sign in to comment.