libnmdc: patch panic() on nil connection
This commit is contained in:
parent
83792a4241
commit
433c1ddac9
@ -314,6 +314,7 @@ func (this *HubConnection) processProtocolMessage(message string) {
|
|||||||
func (this *HubConnection) worker() {
|
func (this *HubConnection) worker() {
|
||||||
var fullBuffer string
|
var fullBuffer string
|
||||||
var err error = nil
|
var err error = nil
|
||||||
|
var nbytes int = 0
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
|
||||||
@ -332,11 +333,13 @@ func (this *HubConnection) worker() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read from socket into our local buffer (blocking)
|
// Read from socket into our local buffer (blocking)
|
||||||
|
if this.conn != nil {
|
||||||
readBuff := make([]byte, 4096)
|
readBuff := make([]byte, 4096)
|
||||||
nbytes, err := this.conn.Read(readBuff)
|
nbytes, err = this.conn.Read(readBuff)
|
||||||
if nbytes > 0 {
|
if nbytes > 0 {
|
||||||
fullBuffer += string(readBuff[0:nbytes])
|
fullBuffer += string(readBuff[0:nbytes])
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Maybe we disconnected
|
// Maybe we disconnected
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user