Pārlūkot izejas kodu

socket: Fix quitting

tags/v0.8.0
Daniel Oaks 7 gadus atpakaļ
vecāks
revīzija
86957d4392
1 mainītis faili ar 12 papildinājumiem un 7 dzēšanām
  1. 12
    7
      irc/socket.go

+ 12
- 7
irc/socket.go Parādīt failu

@@ -140,6 +140,12 @@ func (socket *Socket) RunSocketWriter() {
140 140
 				break
141 141
 			}
142 142
 
143
+			// check number of lines to send
144
+			if len(socket.linesToSend) < 1 {
145
+				fmt.Println("No line to send found on socket writer")
146
+				continue
147
+			}
148
+
143 149
 			// check sendq
144 150
 			var sendQBytes uint64
145 151
 			for _, line := range socket.linesToSend {
@@ -173,17 +179,16 @@ func (socket *Socket) RunSocketWriter() {
173 179
 					break
174 180
 				}
175 181
 			}
176
-
177
-			// check if we're closed
178
-			if socket.Closed {
179
-				break
180
-			}
181 182
 		}
182
-		if errOut {
183
-			// error out, bad stuff happened
183
+		if errOut || socket.Closed {
184
+			// error out or we've been closed
184 185
 			break
185 186
 		}
186 187
 	}
188
+	// empty the lineToSendExists channel
189
+	for 0 < len(socket.lineToSendExists) {
190
+		<-socket.lineToSendExists
191
+	}
187 192
 	//TODO(dan): empty socket.lineToSendExists queue
188 193
 	socket.conn.Close()
189 194
 	if !socket.Closed {

Notiek ielāde…
Atcelt
Saglabāt