diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2013-07-28 22:24:51 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2013-07-28 22:24:51 +0200 |
commit | fd3ac96c0f7806fbc90ff02b305b0ef51894f3db (patch) | |
tree | d28254ea6ed2d6baef9fcefb88665d22009606dc | |
parent | ffeeb7a96c74f1f001495c2311526681e2271a77 (diff) | |
download | busybox-w32-fd3ac96c0f7806fbc90ff02b305b0ef51894f3db.tar.gz busybox-w32-fd3ac96c0f7806fbc90ff02b305b0ef51894f3db.tar.bz2 busybox-w32-fd3ac96c0f7806fbc90ff02b305b0ef51894f3db.zip |
nc: remove some dead code
function old new delta
readwrite 887 841 -46
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/nc_bloaty.c | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/networking/nc_bloaty.c b/networking/nc_bloaty.c index f01e862ae..04baf0316 100644 --- a/networking/nc_bloaty.c +++ b/networking/nc_bloaty.c | |||
@@ -592,8 +592,6 @@ static int readwrite(void) | |||
592 | unsigned rzleft; | 592 | unsigned rzleft; |
593 | unsigned rnleft; | 593 | unsigned rnleft; |
594 | unsigned netretry; /* net-read retry counter */ | 594 | unsigned netretry; /* net-read retry counter */ |
595 | unsigned wretry; /* net-write sanity counter */ | ||
596 | unsigned wfirst; /* one-shot flag to skip first net read */ | ||
597 | unsigned fds_open; | 595 | unsigned fds_open; |
598 | 596 | ||
599 | /* if you don't have all this FD_* macro hair in sys/types.h, you'll have to | 597 | /* if you don't have all this FD_* macro hair in sys/types.h, you'll have to |
@@ -606,20 +604,16 @@ static int readwrite(void) | |||
606 | fds_open = 2; | 604 | fds_open = 2; |
607 | 605 | ||
608 | netretry = 2; | 606 | netretry = 2; |
609 | wfirst = 0; | ||
610 | rzleft = rnleft = 0; | 607 | rzleft = rnleft = 0; |
611 | if (o_interval) | 608 | if (o_interval) |
612 | sleep(o_interval); /* pause *before* sending stuff, too */ | 609 | sleep(o_interval); /* pause *before* sending stuff, too */ |
613 | 610 | ||
614 | errno = 0; /* clear from sleep, close, whatever */ | ||
615 | /* and now the big ol' select shoveling loop ... */ | 611 | /* and now the big ol' select shoveling loop ... */ |
616 | /* nc 1.10 has "while (FD_ISSET(netfd)" here */ | 612 | /* nc 1.10 has "while (FD_ISSET(netfd)" here */ |
617 | while (fds_open) { | 613 | while (fds_open) { |
618 | wretry = 8200; /* more than we'll ever hafta write */ | 614 | unsigned wretry = 8200; /* net-write sanity counter */ |
619 | if (wfirst) { /* any saved stdin buffer? */ | 615 | |
620 | wfirst = 0; /* clear flag for the duration */ | 616 | errno = 0; /* clear from sleep, close, whatever */ |
621 | goto shovel; /* and go handle it first */ | ||
622 | } | ||
623 | ding2 = ding1; /* FD_COPY ain't portable... */ | 617 | ding2 = ding1; /* FD_COPY ain't portable... */ |
624 | /* some systems, notably linux, crap into their select timers on return, so | 618 | /* some systems, notably linux, crap into their select timers on return, so |
625 | we create a expendable copy and give *that* to select. */ | 619 | we create a expendable copy and give *that* to select. */ |
@@ -644,7 +638,7 @@ static int readwrite(void) | |||
644 | if (!netretry) { | 638 | if (!netretry) { |
645 | if (o_verbose > 1) /* normally we don't care */ | 639 | if (o_verbose > 1) /* normally we don't care */ |
646 | fprintf(stderr, "net timeout\n"); | 640 | fprintf(stderr, "net timeout\n"); |
647 | close(netfd); | 641 | /*close(netfd); - redundant, exit will do it */ |
648 | return 0; /* not an error! */ | 642 | return 0; /* not an error! */ |
649 | } | 643 | } |
650 | } | 644 | } |
@@ -681,8 +675,8 @@ Debug("got %d from the net, errno %d", rr, errno); | |||
681 | /* Considered making reads here smaller for UDP mode, but 8192-byte | 675 | /* Considered making reads here smaller for UDP mode, but 8192-byte |
682 | mobygrams are kinda fun and exercise the reassembler. */ | 676 | mobygrams are kinda fun and exercise the reassembler. */ |
683 | if (rr <= 0) { /* at end, or fukt, or ... */ | 677 | if (rr <= 0) { /* at end, or fukt, or ... */ |
684 | FD_CLR(STDIN_FILENO, &ding1); /* disable and close stdin */ | 678 | FD_CLR(STDIN_FILENO, &ding1); /* disable stdin */ |
685 | close(STDIN_FILENO); | 679 | /*close(STDIN_FILENO); - not really necessary */ |
686 | /* Let peer know we have no more data */ | 680 | /* Let peer know we have no more data */ |
687 | /* nc 1.10 doesn't do this: */ | 681 | /* nc 1.10 doesn't do this: */ |
688 | shutdown(netfd, SHUT_WR); | 682 | shutdown(netfd, SHUT_WR); |
@@ -697,23 +691,13 @@ Debug("got %d from the net, errno %d", rr, errno); | |||
697 | Geez, why does this look an awful lot like the big loop in "rsh"? ... | 691 | Geez, why does this look an awful lot like the big loop in "rsh"? ... |
698 | not sure if the order of this matters, but write net -> stdout first. */ | 692 | not sure if the order of this matters, but write net -> stdout first. */ |
699 | 693 | ||
700 | /* sanity check. Works because they're both unsigned... */ | ||
701 | if ((rzleft > 8200) || (rnleft > 8200)) { | ||
702 | holler_error("bogus buffers: %u, %u", rzleft, rnleft); | ||
703 | rzleft = rnleft = 0; | ||
704 | } | ||
705 | /* net write retries sometimes happen on UDP connections */ | ||
706 | if (!wretry) { /* is something hung? */ | ||
707 | holler_error("too many output retries"); | ||
708 | return 1; | ||
709 | } | ||
710 | if (rnleft) { | 694 | if (rnleft) { |
711 | rr = write(STDOUT_FILENO, np, rnleft); | 695 | rr = write(STDOUT_FILENO, np, rnleft); |
712 | if (rr > 0) { | 696 | if (rr > 0) { |
713 | if (o_ofile) /* log the stdout */ | 697 | if (o_ofile) /* log the stdout */ |
714 | oprint('<', (unsigned char *)np, rr); | 698 | oprint('<', (unsigned char *)np, rr); |
715 | np += rr; /* fix up ptrs and whatnot */ | 699 | np += rr; /* fix up ptrs and whatnot */ |
716 | rnleft -= rr; /* will get sanity-checked above */ | 700 | rnleft -= rr; |
717 | wrote_out += rr; /* global count */ | 701 | wrote_out += rr; /* global count */ |
718 | } | 702 | } |
719 | Debug("wrote %d to stdout, errno %d", rr, errno); | 703 | Debug("wrote %d to stdout, errno %d", rr, errno); |
@@ -735,11 +719,15 @@ Debug("wrote %d to net, errno %d", rr, errno); | |||
735 | } /* rzleft */ | 719 | } /* rzleft */ |
736 | if (o_interval) { /* cycle between slow lines, or ... */ | 720 | if (o_interval) { /* cycle between slow lines, or ... */ |
737 | sleep(o_interval); | 721 | sleep(o_interval); |
738 | errno = 0; /* clear from sleep */ | ||
739 | continue; /* ...with hairy select loop... */ | 722 | continue; /* ...with hairy select loop... */ |
740 | } | 723 | } |
741 | if (rzleft || rnleft) { /* shovel that shit till they ain't */ | 724 | if (rzleft || rnleft) { /* shovel that shit till they ain't */ |
742 | wretry--; /* none left, and get another load */ | 725 | wretry--; /* none left, and get another load */ |
726 | /* net write retries sometimes happen on UDP connections */ | ||
727 | if (!wretry) { /* is something hung? */ | ||
728 | holler_error("too many output retries"); | ||
729 | return 1; | ||
730 | } | ||
743 | goto shovel; | 731 | goto shovel; |
744 | } | 732 | } |
745 | } /* while ding1:netfd is open */ | 733 | } /* while ding1:netfd is open */ |