Last active
December 17, 2015 23:09
-
-
Save igm/5687664 to your computer and use it in GitHub Desktop.
Routine leak
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "time" | |
func main() { | |
ch := make(chan bool) | |
go func() { | |
// e.g. do some unpredictable long socket read | |
<-time.After(2 * time.Second) | |
ch <- true | |
}() | |
// e.g. wait for socket read of timeout | |
select { | |
case <-time.After(1 * time.Second): | |
// timeout causes routine leak | |
case <-ch: | |
} | |
<-time.After(3 * time.Second) | |
panic("") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment