aboutsummaryrefslogtreecommitdiff
path: root/networking/telnet.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-10-29 02:33:38 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-10-29 02:33:38 +0200
commitec07420eb914f6ca62273c54790853ccf22636e8 (patch)
tree50b034e4e30babc01edb968e442db82776ebfc1e /networking/telnet.c
parent036dbb9d9ab239bbd7eecad8580876c9c3e57dc5 (diff)
downloadbusybox-w32-ec07420eb914f6ca62273c54790853ccf22636e8.tar.gz
busybox-w32-ec07420eb914f6ca62273c54790853ccf22636e8.tar.bz2
busybox-w32-ec07420eb914f6ca62273c54790853ccf22636e8.zip
telnet: do not check for 0 return from poll (it's impossible)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/telnet.c')
-rw-r--r--networking/telnet.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/networking/telnet.c b/networking/telnet.c
index 0cf28f641..f6fad684c 100644
--- a/networking/telnet.c
+++ b/networking/telnet.c
@@ -603,39 +603,39 @@ int telnet_main(int argc UNUSED_PARAM, char **argv)
603 603
604 signal(SIGINT, record_signo); 604 signal(SIGINT, record_signo);
605 605
606 ufds[0].fd = 0; ufds[1].fd = netfd; 606 ufds[0].fd = STDIN_FILENO;
607 ufds[0].events = ufds[1].events = POLLIN; 607 ufds[0].events = POLLIN;
608 ufds[1].fd = netfd;
609 ufds[1].events = POLLIN;
608 610
609 while (1) { 611 while (1) {
610 switch (poll(ufds, 2, -1)) { 612 if (poll(ufds, 2, -1) < 0) {
611 case 0:
612 /* timeout */
613 case -1:
614 /* error, ignore and/or log something, bay go to loop */ 613 /* error, ignore and/or log something, bay go to loop */
615 if (bb_got_signal) 614 if (bb_got_signal)
616 con_escape(); 615 con_escape();
617 else 616 else
618 sleep(1); 617 sleep(1);
619 break; 618 continue;
620 default: 619 }
621 620
622 if (ufds[0].revents) { 621// FIXME: reads can block. Need full bidirectional buffering.
623 len = safe_read(STDIN_FILENO, G.buf, DATABUFSIZE); 622
624 if (len <= 0) 623 if (ufds[0].revents) {
625 doexit(EXIT_SUCCESS); 624 len = safe_read(STDIN_FILENO, G.buf, DATABUFSIZE);
626 TRACE(0, ("Read con: %d\n", len)); 625 if (len <= 0)
627 handle_net_output(len); 626 doexit(EXIT_SUCCESS);
628 } 627 TRACE(0, ("Read con: %d\n", len));
628 handle_net_output(len);
629 }
629 630
630 if (ufds[1].revents) { 631 if (ufds[1].revents) {
631 len = safe_read(netfd, G.buf, DATABUFSIZE); 632 len = safe_read(netfd, G.buf, DATABUFSIZE);
632 if (len <= 0) { 633 if (len <= 0) {
633 full_write1_str("Connection closed by foreign host\r\n"); 634 full_write1_str("Connection closed by foreign host\r\n");
634 doexit(EXIT_FAILURE); 635 doexit(EXIT_FAILURE);
635 }
636 TRACE(0, ("Read netfd (%d): %d\n", netfd, len));
637 handle_net_input(len);
638 } 636 }
637 TRACE(0, ("Read netfd (%d): %d\n", netfd, len));
638 handle_net_input(len);
639 } 639 }
640 } /* while (1) */ 640 } /* while (1) */
641} 641}