libnmdc: patch panic on read() returning an error (interface type) that can't be cast to net.error
This commit is contained in:
parent
ed64887ddc
commit
649b3dfcab
@ -334,6 +334,20 @@ func (this *HubConnection) processProtocolMessage(message string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CheckIsNetTimeout(err error) bool {
|
||||||
|
if err == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
switch err.(type) {
|
||||||
|
case net.Error:
|
||||||
|
return err.(net.Error).Timeout()
|
||||||
|
|
||||||
|
default:
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (this *HubConnection) worker() {
|
func (this *HubConnection) worker() {
|
||||||
var fullBuffer string
|
var fullBuffer string
|
||||||
var err error = nil
|
var err error = nil
|
||||||
@ -372,7 +386,7 @@ func (this *HubConnection) worker() {
|
|||||||
this.conn.SetReadDeadline(time.Now().Add(SEND_KEEPALIVE_EVERY))
|
this.conn.SetReadDeadline(time.Now().Add(SEND_KEEPALIVE_EVERY))
|
||||||
nbytes, err = this.conn.Read(readBuff)
|
nbytes, err = this.conn.Read(readBuff)
|
||||||
|
|
||||||
if err != nil && err.(net.Error).Timeout() {
|
if CheckIsNetTimeout(err) {
|
||||||
// No data before read deadline
|
// No data before read deadline
|
||||||
err = nil
|
err = nil
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user