Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: experimental/webtry/webtry.go

Issue 638373003: webtry: Do not forget the close the rows. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/webtry/webtry.go
diff --git a/experimental/webtry/webtry.go b/experimental/webtry/webtry.go
index 00de9bc455810b49552d4f606ec3c5c6a68ee32c..ea59bc1c422b7d7d57821d4d663229644f356831 100644
--- a/experimental/webtry/webtry.go
+++ b/experimental/webtry/webtry.go
@@ -303,11 +303,11 @@ func init() {
func writeOutAllSourceImages() {
// Pull all the source images from the db and write them out to inout.
rows, err := db.Query("SELECT id, image, create_ts FROM source_images ORDER BY create_ts DESC")
-
if err != nil {
glog.Errorf("Failed to open connection to SQL server: %q\n", err)
panic(err)
}
+ defer rows.Close()
for rows.Next() {
var id int
var image []byte
@@ -478,10 +478,10 @@ func sourcesHandler(w http.ResponseWriter, r *http.Request) {
glog.Infof("Sources Handler: %q\n", r.URL.Path)
if r.Method == "GET" {
rows, err := db.Query("SELECT id, create_ts FROM source_images WHERE hidden=0 ORDER BY create_ts DESC")
-
if err != nil {
http.Error(w, fmt.Sprintf("Failed to query sources: %s.", err), 500)
}
+ defer rows.Close()
sources := make([]Sources, 0, 0)
for rows.Next() {
var id int
@@ -577,12 +577,12 @@ type Recent struct {
func recentHandler(w http.ResponseWriter, r *http.Request) {
glog.Infof("Recent Handler: %q\n", r.URL.Path)
- var err error
rows, err := db.Query("SELECT create_ts, hash FROM webtry ORDER BY create_ts DESC LIMIT 20")
if err != nil {
http.NotFound(w, r)
return
}
+ defer rows.Close()
recent := []Try{}
for rows.Next() {
var hash string
@@ -654,6 +654,7 @@ func workspaceHandler(w http.ResponseWriter, r *http.Request) {
reportError(w, r, err, "Failed to select.")
return
}
+ defer rows.Close()
for rows.Next() {
var hash string
var create_ts time.Time
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698