mirror of
https://github.com/emqx/neuron.git
synced 2026-10-17 04:40:42 +08:00
improve(connection): donot close fd if tty read returns 0
This commit is contained in:
@@ -405,13 +405,23 @@ ssize_t neu_conn_recv(neu_conn_t *conn, uint8_t *buf, ssize_t len)
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (ret <= 0) {
|
||||
zlog_error(conn->param.log,
|
||||
"conn fd: %d, recv buf len %zd, ret: %zd, errno: %s(%d)",
|
||||
conn->fd, len, ret, strerror(errno), errno);
|
||||
if (ret == 0 || (ret == -1 && errno != EAGAIN)) {
|
||||
if (conn->param.type == NEU_CONN_TTY_CLIENT) {
|
||||
if (ret == -1) {
|
||||
zlog_error(
|
||||
conn->param.log,
|
||||
"tty conn fd: %d, recv buf len %zd, ret: %zd, errno: %s(%d)",
|
||||
conn->fd, len, ret, strerror(errno), errno);
|
||||
conn_disconnect(conn);
|
||||
}
|
||||
} else {
|
||||
if (ret <= 0) {
|
||||
zlog_error(conn->param.log,
|
||||
"conn fd: %d, recv buf len %zd, ret: %zd, errno: %s(%d)",
|
||||
conn->fd, len, ret, strerror(errno), errno);
|
||||
if (ret == 0 || (ret == -1 && errno != EAGAIN)) {
|
||||
conn_disconnect(conn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&conn->mtx);
|
||||
|
||||
Reference in New Issue
Block a user