all repos — honk @ 75e7409804501977a424572e891d9c779d0e8968

my fork of honk

make sure every rows is closed
Ted Unangst tedu@tedunangst.com
Tue, 17 Sep 2019 09:45:02 -0400
commit

75e7409804501977a424572e891d9c779d0e8968

parent

e617c6d87fd6ea08a77a7d2aad722dfa2b2086f8

2 files changed, 26 insertions(+), 19 deletions(-)

jump to
M deliverator.godeliverator.go

@@ -109,6 +109,29 @@ }

var pokechan = make(chan int) +func getdoovers() []Doover { + rows, err := stmtGetDoovers.Query() + if err != nil { + log.Printf("wat?") + time.Sleep(1 * time.Minute) + return nil + } + defer rows.Close() + var doovers []Doover + for rows.Next() { + var d Doover + var dt string + err := rows.Scan(&d.ID, &dt) + if err != nil { + log.Printf("error scanning dooverid: %s", err) + continue + } + d.When, _ = time.Parse(dbtimeformat, dt) + doovers = append(doovers, d) + } + return doovers +} + func redeliverator() { sleeper := time.NewTimer(0) for {

@@ -121,25 +144,8 @@ time.Sleep(5 * time.Second)

case <-sleeper.C: } - rows, err := stmtGetDoovers.Query() - if err != nil { - log.Printf("wat?") - time.Sleep(1 * time.Minute) - continue - } - var doovers []Doover - for rows.Next() { - var d Doover - var dt string - err := rows.Scan(&d.ID, &dt) - if err != nil { - log.Printf("error scanning dooverid: %s", err) - continue - } - d.When, _ = time.Parse(dbtimeformat, dt) - doovers = append(doovers, d) - } - rows.Close() + doovers := getdoovers() + now := time.Now().UTC() nexttime := now.Add(24 * time.Hour) for _, d := range doovers {
M web.goweb.go

@@ -586,6 +586,7 @@ if err != nil {

log.Printf("selection error: %s", err) return } + defer rows.Close() var onts [][]string for rows.Next() { var o string