Read a empty data means connection error
This commit is contained in:
parent
0d6d1e114f
commit
a8f7c8ab9d
@ -82,7 +82,7 @@ func (client *Client) inLoop() {
|
||||
for {
|
||||
rel, err := client.read()
|
||||
if err != nil {
|
||||
if err == common.ErrEmptyReading {
|
||||
if err == common.ErrConnection {
|
||||
client.Close()
|
||||
break
|
||||
}
|
||||
@ -123,7 +123,7 @@ func (client *Client) read() (data []byte, err error) {
|
||||
if n, err = client.conn.Read(buf); err != nil {
|
||||
if err == io.EOF && n == 0 {
|
||||
if data == nil {
|
||||
err = common.ErrEmptyReading
|
||||
err = common.ErrConnection
|
||||
return
|
||||
}
|
||||
break
|
||||
|
@ -22,7 +22,7 @@ var (
|
||||
ErrOutOfCap = errors.New("Out of the capability.")
|
||||
ErrNotConn = errors.New("Did not connect to job server.")
|
||||
ErrFuncNotFound = errors.New("The function was not found.")
|
||||
ErrEmptyReading = errors.New("Empty reading.")
|
||||
ErrConnection = errors.New("Connection error.")
|
||||
)
|
||||
func DisablePanic() {recover()}
|
||||
|
||||
|
@ -61,7 +61,8 @@ func (a *agent) inLoop() {
|
||||
}
|
||||
rel, err := a.read()
|
||||
if err != nil {
|
||||
if err == common.ErrEmptyReading {
|
||||
if err == common.ErrConnection {
|
||||
// TODO: reconnection
|
||||
break
|
||||
}
|
||||
a.worker.err(err)
|
||||
@ -102,7 +103,7 @@ func (a *agent) read() (data []byte, err error) {
|
||||
if n, err = a.conn.Read(buf); err != nil {
|
||||
if err == io.EOF && n == 0 {
|
||||
if data == nil {
|
||||
err = common.ErrEmptyReading
|
||||
err = common.ErrConnection
|
||||
return
|
||||
}
|
||||
break
|
||||
|
Loading…
Reference in New Issue
Block a user