Skip to content

Commit

Permalink
pathdb: Use context in GetNextQuery (#1991)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukedirtwalker authored Oct 17, 2018
1 parent 6348c08 commit 6a24602
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions go/lib/pathdb/pathdbtest/pathdbtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,10 @@ func testNextQuery(t *testing.T, pathDB pathdb.PathDB) {
SoMsg("Should return updated time", dbT.Unix(), ShouldEqual, newT.Unix())
dbT, err = pathDB.GetNextQuery(ctx, xtest.MustParseIA("1-ff00:0:122"))
SoMsg("Should be nil", dbT, ShouldBeNil)
ctx, cancelF = context.WithDeadline(context.Background(), time.Now().Add(-3*time.Second))
defer cancelF()
_, err = pathDB.GetNextQuery(ctx, xtest.MustParseIA("1-ff00:0:122"))
SoMsg("Should error", err, ShouldNotBeNil)
})
}

Expand Down
4 changes: 2 additions & 2 deletions go/lib/pathdb/sqlite/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,8 @@ func (b *Backend) GetNextQuery(ctx context.Context, dst addr.IA) (*time.Time, er
if b.db == nil {
return nil, common.NewBasicError("No database open", nil)
}
rows, err := b.db.Query("SELECT NextQuery from NextQuery WHERE IsdID = ? AND AsID = ?",
dst.I, dst.A)
query := "SELECT NextQuery from NextQuery WHERE IsdID = ? AND AsID = ?"
rows, err := b.db.QueryContext(ctx, query, dst.I, dst.A)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 6a24602

Please sign in to comment.