diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2019-01-06 19:06:01 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-01-06 19:06:01 +0100 |
commit | 39b18196f89a6f595d47c2a9c3a62c50d413c054 (patch) | |
tree | ef4db62c99834be553c79d7f00daff22f0620456 | |
parent | 935afafcf37e38290e4cc126e328a02877d74fc0 (diff) | |
download | busybox-w32-39b18196f89a6f595d47c2a9c3a62c50d413c054.tar.gz busybox-w32-39b18196f89a6f595d47c2a9c3a62c50d413c054.tar.bz2 busybox-w32-39b18196f89a6f595d47c2a9c3a62c50d413c054.zip |
telnetd: fix bad interaction with vhangup() from login
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/telnetd.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/networking/telnetd.c b/networking/telnetd.c index a6bafa21d..caef15181 100644 --- a/networking/telnetd.c +++ b/networking/telnetd.c | |||
@@ -865,11 +865,25 @@ int telnetd_main(int argc UNUSED_PARAM, char **argv) | |||
865 | skip3: | 865 | skip3: |
866 | if (/*ts->size2 < BUFSIZE &&*/ FD_ISSET(ts->ptyfd, &rdfdset)) { | 866 | if (/*ts->size2 < BUFSIZE &&*/ FD_ISSET(ts->ptyfd, &rdfdset)) { |
867 | /* Read from pty to buffer 2 */ | 867 | /* Read from pty to buffer 2 */ |
868 | int eio = 0; | ||
869 | read_pty: | ||
868 | count = MIN(BUFSIZE - ts->rdidx2, BUFSIZE - ts->size2); | 870 | count = MIN(BUFSIZE - ts->rdidx2, BUFSIZE - ts->size2); |
869 | count = safe_read(ts->ptyfd, TS_BUF2(ts) + ts->rdidx2, count); | 871 | count = safe_read(ts->ptyfd, TS_BUF2(ts) + ts->rdidx2, count); |
870 | if (count <= 0) { | 872 | if (count <= 0) { |
871 | if (count < 0 && errno == EAGAIN) | 873 | if (count < 0) { |
872 | goto skip4; | 874 | if (errno == EAGAIN) |
875 | goto skip4; | ||
876 | /* login process might call vhangup(), | ||
877 | * which causes intermittent EIOs on read above | ||
878 | * (observed on kernel 4.12.0). Try up to 10 ms. | ||
879 | */ | ||
880 | if (errno == EIO && eio < 10) { | ||
881 | eio++; | ||
882 | //bb_error_msg("EIO pty %u", eio); | ||
883 | usleep(1000); | ||
884 | goto read_pty; | ||
885 | } | ||
886 | } | ||
873 | goto kill_session; | 887 | goto kill_session; |
874 | } | 888 | } |
875 | ts->size2 += count; | 889 | ts->size2 += count; |