source: npl/overig/netcat_openbsd/patches/0004-poll-hup.patch @ 94ad01e

perl-5.22
Last change on this file since 94ad01e was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100644
File size: 1.2 KB
  • netcat.c

    From: Aron Xu <aron@debian.org>
    Date: Mon, 13 Feb 2012 15:08:33 +0800
    Subject: poll hup
    
    ---
     netcat.c |   24 +++++++++++++++++-------
     1 file changed, 17 insertions(+), 7 deletions(-)
    
    diff --git a/netcat.c b/netcat.c
    index d912544..fdaca44 100644
    a b readwrite(int nfd) 
    884884                        if ((n = read(nfd, buf, plen)) < 0)
    885885                                return;
    886886                        else if (n == 0) {
    887                                 shutdown(nfd, SHUT_RD);
    888                                 pfd[0].fd = -1;
    889                                 pfd[0].events = 0;
     887                                goto shutdown_rd;
    890888                        } else {
    891889                                if (tflag)
    892890                                        atelnet(nfd, buf, n);
    readwrite(int nfd) 
    894892                                        return;
    895893                        }
    896894                }
     895                else if (pfd[0].revents & POLLHUP) {
     896                shutdown_rd:
     897                        shutdown(nfd, SHUT_RD);
     898                        pfd[0].fd = -1;
     899                        pfd[0].events = 0;
     900                }
    897901
    898                 if (!dflag && pfd[1].revents & POLLIN) {
     902                if (!dflag) {
     903                    if(pfd[1].revents & POLLIN) {
    899904                        if ((n = read(wfd, buf, plen)) < 0)
    900905                                return;
    901906                        else if (n == 0) {
    902                                 shutdown(nfd, SHUT_WR);
    903                                 pfd[1].fd = -1;
    904                                 pfd[1].events = 0;
     907                                goto shutdown_wr;
    905908                        } else {
    906909                                if (atomicio(vwrite, nfd, buf, n) != n)
    907910                                        return;
    908911                        }
     912                        }
     913                        else if (pfd[1].revents & POLLHUP) {
     914                        shutdown_wr:
     915                                shutdown(nfd, SHUT_WR);
     916                                pfd[1].fd = -1;
     917                                pfd[1].events = 0;
     918                        }
    909919                }
    910920        }
    911921}
Note: See TracBrowser for help on using the repository browser.