Explorar el Código

ensure the nick timeout mechanism is cleaned up on client quit

tags/v0.11.0-beta
Shivaram Lingamneni hace 6 años
padre
commit
945dec9964
Se han modificado 2 ficheros con 20 adiciones y 3 borrados
  1. 2
    3
      irc/client.go
  2. 18
    0
      irc/idletimer.go

+ 2
- 3
irc/client.go Ver fichero

686
 	}
686
 	}
687
 
687
 
688
 	// clean up self
688
 	// clean up self
689
-	if client.idletimer != nil {
690
-		client.idletimer.Stop()
691
-	}
689
+	client.idletimer.Stop()
690
+	client.nickTimer.Stop()
692
 
691
 
693
 	client.server.accounts.Logout(client)
692
 	client.server.accounts.Logout(client)
694
 
693
 

+ 18
- 0
irc/idletimer.go Ver fichero

127
 
127
 
128
 // Stop stops counting idle time.
128
 // Stop stops counting idle time.
129
 func (it *IdleTimer) Stop() {
129
 func (it *IdleTimer) Stop() {
130
+	if it == nil {
131
+		return
132
+	}
133
+
130
 	it.Lock()
134
 	it.Lock()
131
 	defer it.Unlock()
135
 	defer it.Unlock()
132
 	it.state = TimerDead
136
 	it.state = TimerDead
232
 	}
236
 	}
233
 }
237
 }
234
 
238
 
239
+// Stop stops counting time and cleans up the timer
240
+func (nt *NickTimer) Stop() {
241
+	if nt == nil {
242
+		return
243
+	}
244
+
245
+	nt.Lock()
246
+	defer nt.Unlock()
247
+	if nt.timer != nil {
248
+		nt.timer.Stop()
249
+		nt.timer = nil
250
+	}
251
+}
252
+
235
 func (nt *NickTimer) sendWarning() {
253
 func (nt *NickTimer) sendWarning() {
236
 	baseNotice := "Nickname is reserved; you must change it or authenticate to NickServ within %v"
254
 	baseNotice := "Nickname is reserved; you must change it or authenticate to NickServ within %v"
237
 	nt.client.Notice(fmt.Sprintf(nt.client.t(baseNotice), nt.timeout))
255
 	nt.client.Notice(fmt.Sprintf(nt.client.t(baseNotice), nt.timeout))

Loading…
Cancelar
Guardar