]> Cypherpunks repositories - gostls13.git/commit
text/template: shut down lexing goroutine on error
authorRob Pike <r@golang.org>
Mon, 4 May 2015 20:09:31 +0000 (13:09 -0700)
committerRob Pike <r@golang.org>
Tue, 5 May 2015 16:02:19 +0000 (16:02 +0000)
commit64c39a3093db3976201697bb817d5705afc66bed
tree5a4a1c8c92486044104d3a74b9a78792532452a9
parent5a828cfcde20c25b9b3a3387159a77eb084383b8
text/template: shut down lexing goroutine on error

When a parse error occurred, the lexing goroutine would lay idle.
It's not likely a problem but if the program is for some reason
accepting badly formed data repeatedly, it's wasteful.

The solution is easy: Just drain the input on error. We know this
will succeed because the input is always a string and is therefore
guaranteed finite.

With debugging prints in the package tests I've shown this is effective,
shutting down 79 goroutines that would otherwise linger, out of 123 total.

Fixes #10574.

Change-Id: I8aa536e327b219189a7e7f604a116fa562ae1c39
Reviewed-on: https://go-review.googlesource.com/9658
Reviewed-by: Russ Cox <rsc@golang.org>
src/text/template/parse/lex.go
src/text/template/parse/lex_test.go
src/text/template/parse/parse.go