all repos — honk @ 0d1335deb0f126d81d2bc2a0b2d69b4c39b087db

my fork of honk

close some queries when done
Ted Unangst tedu@tedunangst.com
Sun, 16 Jun 2019 21:21:56 -0400
commit

0d1335deb0f126d81d2bc2a0b2d69b4c39b087db

parent

2d799a8e563e05898bbc8d2ccbd93f900915d446

2 files changed, 6 insertions(+), 3 deletions(-)

jump to
M fun.gofun.go

@@ -476,6 +476,7 @@ log.Printf("error getting thumbbiters: %s", err)

return } defer rows.Close() + thumblock.Lock() defer thumblock.Unlock() thumbbiters = make(map[int64]map[string]bool)
M honk.gohonk.go

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

log.Printf("query err: %s", err) return } + defer rows.Close() for rows.Next() { var s string rows.Scan(&s)

@@ -1123,13 +1124,13 @@ Wherefore string

} func zonkzone(w http.ResponseWriter, r *http.Request) { - db := opendatabase() userinfo := login.GetUserInfo(r) - rows, err := db.Query("select zonkerid, name, wherefore from zonkers where userid = ?", userinfo.UserID) + rows, err := stmtGetZonkers.Query(userinfo.UserID) if err != nil { log.Printf("err: %s", err) return } + defer rows.Close() var zonkers []Zonker for rows.Next() { var z Zonker

@@ -1428,7 +1429,7 @@ var stmtHonksByHonker, stmtSaveHonk, stmtFileData, stmtWhatAbout *sql.Stmt

var stmtFindXonk, stmtSaveDonk, stmtFindFile, stmtSaveFile *sql.Stmt var stmtAddDoover, stmtGetDoovers, stmtLoadDoover, stmtZapDoover *sql.Stmt var stmtHasHonker, stmtThumbBiters, stmtZonkIt, stmtZonkDonks, stmtSaveZonker *sql.Stmt -var stmtRecentHonkers, stmtGetXonker, stmtSaveXonker *sql.Stmt +var stmtGetZonkers, stmtRecentHonkers, stmtGetXonker, stmtSaveXonker *sql.Stmt func preparetodie(db *sql.DB, s string) *sql.Stmt { stmt, err := db.Prepare(s)

@@ -1474,6 +1475,7 @@ stmtGetDoovers = preparetodie(db, "select dooverid, dt from doovers")

stmtLoadDoover = preparetodie(db, "select tries, username, rcpt, msg from doovers where dooverid = ?") stmtZapDoover = preparetodie(db, "delete from doovers where dooverid = ?") stmtThumbBiters = preparetodie(db, "select userid, name, wherefore from zonkers where (wherefore = 'zonker' or wherefore = 'zurl' or wherefore = 'zword')") + stmtGetZonkers = preparetodie(db, "select zonkerid, name, wherefore from zonkers where userid = ?") stmtSaveZonker = preparetodie(db, "insert into zonkers (userid, name, wherefore) values (?, ?, ?)") stmtGetXonker = preparetodie(db, "select info from xonkers where name = ? and flavor = ?") stmtSaveXonker = preparetodie(db, "insert into xonkers (name, info, flavor) values (?, ?, ?)")