X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=main.go;h=facfa6569e58a660e078614f8763900945b2328f;hb=94ddec26f9f9ff4607c9ad6f9ca1e6b82ae0af71;hp=94c0036524a2b778482a10cdd82f68b6d897491a;hpb=d38bc6ef7c4b5a914e5c3e492c1efdc84944fbd1;p=pstop.git diff --git a/main.go b/main.go index 94c0036..facfa65 100644 --- a/main.go +++ b/main.go @@ -59,6 +59,9 @@ func connect_by_defaults_file( defaults_file string ) *sql.DB { log.Fatal(err) } + // deliberately limit the pool size to 5 to avoid "problems" if any queries hang. + dbh.SetMaxOpenConns(5) // hard-coded value! + return dbh } @@ -116,6 +119,7 @@ func usage() { // be found. func validate_mysql_version(dbh *sql.DB) error { var tables = [...]string{ + "performance_schema.events_waits_summary_global_by_event_name", "performance_schema.file_summary_by_instance", "performance_schema.table_io_waits_summary_by_table", "performance_schema.table_lock_waits_summary_by_table", @@ -233,13 +237,11 @@ func main() { signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM) state.Setup(dbh) - - finished := false - for !finished { + for !state.Finished() { select { case <-done: fmt.Println("exiting") - finished = true + state.SetFinished() case sig := <-sigChan: fmt.Println("Caught a signal", sig) done <- struct{}{} @@ -253,7 +255,7 @@ func main() { case termbox.EventKey: // actions depend on key switch event.Key { case termbox.KeyCtrlZ, termbox.KeyCtrlC, termbox.KeyEsc: - finished = true + state.SetFinished() case termbox.KeyArrowLeft: // left arrow change to previous display mode state.DisplayPrevious() state.Display() @@ -271,7 +273,7 @@ func main() { case 'h', '?': // help state.SetHelp(!state.Help()) case 'q': // quit - finished = true + state.SetFinished() case 't': // toggle between absolute/relative statistics state.SetWantRelativeStats(!state.WantRelativeStats()) state.Display()