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