|
@@ -50,7 +50,12 @@ func NewSocket(conn net.Conn, maxSendQBytes uint64) Socket {
|
50
|
50
|
// Close stops a Socket from being able to send/receive any more data.
|
51
|
51
|
func (socket *Socket) Close() {
|
52
|
52
|
socket.Closed = true
|
53
|
|
- // socket will close once all data has been sent
|
|
53
|
+
|
|
54
|
+ // 'send data' to force close loop to happen
|
|
55
|
+ socket.linesToSendMutex.Lock()
|
|
56
|
+ socket.linesToSend = append(socket.linesToSend, "")
|
|
57
|
+ socket.linesToSendMutex.Unlock()
|
|
58
|
+ go socket.fillLineToSendExists()
|
54
|
59
|
}
|
55
|
60
|
|
56
|
61
|
// CertFP returns the fingerprint of the certificate provided by the client.
|
|
@@ -155,12 +160,21 @@ func (socket *Socket) RunSocketWriter() {
|
155
|
160
|
}
|
156
|
161
|
|
157
|
162
|
// write data
|
158
|
|
- _, err := socket.conn.Write([]byte(data))
|
159
|
|
- if err != nil {
|
160
|
|
- errOut = true
|
161
|
|
- fmt.Println(err.Error())
|
|
163
|
+ if 0 < len(data) {
|
|
164
|
+ _, err := socket.conn.Write([]byte(data))
|
|
165
|
+ if err != nil {
|
|
166
|
+ errOut = true
|
|
167
|
+ fmt.Println(err.Error())
|
|
168
|
+ break
|
|
169
|
+ }
|
|
170
|
+ }
|
|
171
|
+
|
|
172
|
+ // check if we're closed
|
|
173
|
+ if socket.Closed {
|
|
174
|
+ socket.linesToSendMutex.Unlock()
|
162
|
175
|
break
|
163
|
176
|
}
|
|
177
|
+
|
164
|
178
|
socket.linesToSendMutex.Unlock()
|
165
|
179
|
}
|
166
|
180
|
if errOut {
|