File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -173,13 +173,13 @@ func (w *websocketConnection) close() {
173
173
w .shipWriteChannel = nil
174
174
}
175
175
176
- w .mux .Unlock ()
177
-
178
176
if w .conn != nil {
179
177
w .conn .Close ()
180
178
}
181
179
182
180
w .isConnectionClosed = true
181
+
182
+ w .mux .Unlock ()
183
183
})
184
184
}
185
185
@@ -193,10 +193,13 @@ func (w *websocketConnection) InitDataProcessing(dataProcessing ShipDataProcessi
193
193
194
194
// write a message to the websocket connection
195
195
func (w * websocketConnection ) WriteMessageToDataConnection (message []byte ) error {
196
- if w .conn == nil {
196
+ if w .conn == nil || w . shipWriteChannel == nil || w . isConnClosed () {
197
197
return errors .New ("connection is not initialized" )
198
198
}
199
199
200
+ w .mux .Lock ()
201
+ defer w .mux .Unlock ()
202
+
200
203
w .shipWriteChannel <- message
201
204
return nil
202
205
}
You can’t perform that action at this time.
0 commit comments