3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-22 18:52:41 +01:00

don't close socket channels to avoid panics

This commit is contained in:
Jeremy Latt 2014-02-09 19:59:25 -08:00
parent db0f494604
commit 3fd73e3252

View File

@ -13,7 +13,6 @@ func StringReadChan(conn net.Conn) <-chan string {
ch := make(chan string) ch := make(chan string)
reader := bufio.NewReader(conn) reader := bufio.NewReader(conn)
go func() { go func() {
defer close(ch)
for { for {
line, err := reader.ReadString('\n') line, err := reader.ReadString('\n')
if err != nil { if err != nil {
@ -46,7 +45,6 @@ func StringWriteChan(conn net.Conn) chan<- string {
ch := make(chan string) ch := make(chan string)
writer := bufio.NewWriter(conn) writer := bufio.NewWriter(conn)
go func() { go func() {
defer close(ch)
for str := range ch { for str := range ch {
if DEBUG_NET { if DEBUG_NET {
log.Printf("%s ← %s %s", conn.RemoteAddr(), conn.LocalAddr(), str) log.Printf("%s ← %s %s", conn.RemoteAddr(), conn.LocalAddr(), str)