1
0
Fork 0
mirror of https://github.com/fluffle/goirc synced 2025-05-12 10:41:42 +00:00

New race detector finds more bugs in my crappy code :-)

This commit is contained in:
Alex Bramley 2014-09-05 15:39:56 +01:00
parent 7c53f41c56
commit 58eaab3f1f
2 changed files with 10 additions and 4 deletions

View file

@ -236,10 +236,12 @@ func (conn *Conn) postConnect(start bool) {
bufio.NewReader(conn.sock),
bufio.NewWriter(conn.sock))
if start {
conn.wg.Add(3)
go conn.send()
go conn.recv()
go conn.runLoop()
if conn.cfg.PingFreq > 0 {
conn.wg.Add(1)
go conn.ping()
}
}
@ -252,7 +254,6 @@ func hasPort(s string) bool {
// goroutine to pass data from output channel to write()
func (conn *Conn) send() {
conn.wg.Add(1)
defer conn.wg.Done()
for {
select {
@ -267,7 +268,6 @@ func (conn *Conn) send() {
// receive one \r\n terminated line from peer, parse and dispatch it
func (conn *Conn) recv() {
conn.wg.Add(1)
for {
s, err := conn.io.ReadString('\n')
if err != nil {
@ -293,7 +293,6 @@ func (conn *Conn) recv() {
// Repeatedly pings the server every PingFreq seconds (no matter what)
func (conn *Conn) ping() {
conn.wg.Add(1)
defer conn.wg.Done()
tick := time.NewTicker(conn.cfg.PingFreq)
for {
@ -310,7 +309,6 @@ func (conn *Conn) ping() {
// goroutine to dispatch events for lines received on input channel
func (conn *Conn) runLoop() {
conn.wg.Add(1)
defer conn.wg.Done()
for {
select {