You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2020/02/04 22:07:45 UTC
[incubator-nuttx-apps] 06/06: Check POLLHUP and POLLERR in telnet
poll loop
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch pr50
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
commit c2e28faeb5cae7b8ea82bcc357c2c8c471f500a9
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Tue Feb 4 23:12:02 2020 +0800
Check POLLHUP and POLLERR in telnet poll loop
to handle the remote end close correctly
Change-Id: I3297f08aab4f56fa18e1805de349cf4e61de90dc
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
system/telnet/telnet_chatd.c | 4 ++--
system/telnet/telnet_client.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/system/telnet/telnet_chatd.c b/system/telnet/telnet_chatd.c
index 356aac8..17c4a7d 100644
--- a/system/telnet/telnet_chatd.c
+++ b/system/telnet/telnet_chatd.c
@@ -443,7 +443,7 @@ int main(int argc, FAR char *argv[])
/* New connection */
- if (pfd[MAX_USERS].revents & POLLIN)
+ if (pfd[MAX_USERS].revents & (POLLIN | POLLERR | POLLHUP))
{
/* Accept the sock */
@@ -496,7 +496,7 @@ int main(int argc, FAR char *argv[])
continue;
}
- if (pfd[i].revents & POLLIN)
+ if (pfd[i].revents & (POLLIN | POLLERR | POLLHUP))
{
if ((ret = recv(g_users[i].sock, buffer, sizeof(buffer), 0)) > 0)
{
diff --git a/system/telnet/telnet_client.c b/system/telnet/telnet_client.c
index 9c9c517..04c17a7 100644
--- a/system/telnet/telnet_client.c
+++ b/system/telnet/telnet_client.c
@@ -411,7 +411,7 @@ int main(int argc, FAR char *argv[])
{
/* Read from stdin */
- if (pfd[0].revents & POLLIN)
+ if (pfd[0].revents & (POLLIN | POLLERR | POLLHUP))
{
ret = std_readline(buffer, sizeof(buffer));
if (ret > 0)
@@ -431,7 +431,7 @@ int main(int argc, FAR char *argv[])
/* Read from client */
- if (pfd[1].revents & POLLIN)
+ if (pfd[1].revents & (POLLIN | POLLERR | POLLHUP))
{
if ((ret = recv(sock, buffer, sizeof(buffer), 0)) > 0)
{