lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lynx-dev lynx2.8.1pre.11


From: Bela Lubkin
Subject: Re: lynx-dev lynx2.8.1pre.11
Date: Mon, 19 Oct 1998 17:33:29 -0700

Tom Dickey wrote:

> > > * modify waitpid logic in nsl-fork support to handle a case where the 
> > > child
> > >   process exits without reporting anything (reported by Serge Munhoven) - 
> > > BL

> ok (btw, it doesn't compile on Linux, which is why I ifdef'd it)

Linux doesn't have WNOWAIT?  Huh.  Ok, well, the code didn't really need
it, so here is a rewrite.

Following are *two* patches, to be applied sequentially to the pre.11
HTTCP.c.  The first one applies all the substantive changes.  The second
renames some variables, including splitting one multi-purpose variable
into three.  I submit them as separate patches for your ease of merging:
the substantive changes are small and easily understood, but would have
been lost in the noise of the renaming.  The code itself is easier to
understand after the renaming (in fact, I should have done the patches
in opposite order, but too late for that).

>Bela<

=============================================================================
*** HTTCP.c.orig        Sat Oct 17 14:20:41 1998
--- HTTCP.c.orig+       Mon Oct 19 17:21:26 1998
***************
*** 455,459 ****
            int dns_patience = 30; /* how many seconds will we wait for DNS? */
- #ifdef WNOWAIT
            int child_exited = 0;
- #endif
  
--- 455,457 ----
***************
*** 561,563 ****
                    cst1 = read(pfd[0], (void *)&cstat, sizeof cstat);
!                   if (cstat == sizeof soc_in->sin_addr) {
                        /*
--- 559,562 ----
                    cst1 = read(pfd[0], (void *)&cstat, sizeof cstat);
!                   if (cst1 == sizeof cstat &&
!                       cstat == sizeof soc_in->sin_addr) {
                        /*
***************
*** 571,573 ****
                    */
!                   waitret = waitpid(fpid, &cst1, WNOHANG);
                    if (!WIFEXITED(cst1) && !WIFSIGNALED(cst1)) {
--- 570,573 ----
                    */
!                   if (!child_exited)
!                       waitret = waitpid(fpid, &cst1, WNOHANG);
                    if (!WIFEXITED(cst1) && !WIFSIGNALED(cst1)) {
***************
*** 579,581 ****
  
- #ifdef WNOWAIT
                /*
--- 579,580 ----
***************
*** 590,600 ****
                */
!               if ((waitret = waitpid(fpid, &cst1, WNOHANG | WNOWAIT)) > 0)
                    child_exited = 1;
! #else
!               /*
!               **  End loop if child exited.
!               */
!               if ((waitret = waitpid(fpid, &cst1, WNOHANG)) > 0)
!                   break;
! #endif
  
--- 589,600 ----
                */
!               if ((waitret = waitpid(fpid, &cst1, WNOHANG)) > 0) {
!                   /*
!                   **  Data will be arriving right now, so make sure we
!                   **  don't short-circuit out for too many loops, and
!                   **  skip the interrupt check.  -BL
!                   */
                    child_exited = 1;
!                   cycle--;
!                   continue;
!               }
  
=============================================================================
*** HTTCP.c.orig+       Mon Oct 19 17:21:26 1998
--- HTTCP.c     Mon Oct 19 17:16:37 1998
***************
*** 451,453 ****
            pid_t fpid, waitret;
!           int pfd[2], cstat, cst1 = 0, cycle = 0;
            fd_set readfds;
--- 451,453 ----
            pid_t fpid, waitret;
!           int pfd[2], h_length, selret, readret, waitstat = 0, cycle = 0;
            fd_set readfds;
***************
*** 496,503 ****
                if (OK_HOST(phost))
!                       cstat = phost->h_length;
                else
!                       cstat = 0;
!               write(pfd[1], &cstat, sizeof cstat);
  
!               if (cstat) {
                    /*
--- 496,503 ----
                if (OK_HOST(phost))
!                       h_length = phost->h_length;
                else
!                       h_length = 0;
!               write(pfd[1], &h_length, sizeof h_length);
  
!               if (h_length) {
                    /*
***************
*** 549,556 ****
                if (socks_flag)
!                   cst1 = Rselect(pfd[0] + 1, (void *)&readfds, NULL, NULL, 
&timeout);
                else
  #endif /* SOCKS */
!                   cst1 = select(pfd[0] + 1, (void *)&readfds, NULL, NULL, 
&timeout);
  
!               if ((cst1 > 0) && FD_ISSET(pfd[0], &readfds)) {
                    /*
--- 549,556 ----
                if (socks_flag)
!                   selret = Rselect(pfd[0] + 1, (void *)&readfds, NULL, NULL, 
&timeout);
                else
  #endif /* SOCKS */
!                   selret = select(pfd[0] + 1, (void *)&readfds, NULL, NULL, 
&timeout);
  
!               if ((selret > 0) && FD_ISSET(pfd[0], &readfds)) {
                    /*
***************
*** 558,562 ****
                    */
!                   cst1 = read(pfd[0], (void *)&cstat, sizeof cstat);
!                   if (cst1 == sizeof cstat &&
!                       cstat == sizeof soc_in->sin_addr) {
                        /*
--- 558,562 ----
                    */
!                   readret = read(pfd[0], (void *)&h_length, sizeof h_length);
!                   if (readret == sizeof h_length &&
!                       h_length == sizeof soc_in->sin_addr) {
                        /*
***************
*** 564,567 ****
                        */
!                       cst1 = read(pfd[0], (void *)&soc_in->sin_addr, cstat);
!                       if (cst1 == cstat) success = 1;
                    }
--- 564,567 ----
                        */
!                       readret = read(pfd[0], (void *)&soc_in->sin_addr, 
h_length);
!                       if (readret == h_length) success = 1;
                    }
***************
*** 571,576 ****
                    if (!child_exited)
!                       waitret = waitpid(fpid, &cst1, WNOHANG);
!                   if (!WIFEXITED(cst1) && !WIFSIGNALED(cst1)) {
                        kill(fpid, SIGTERM);
!                       waitret = waitpid(fpid, &cst1, WNOHANG);
                    }
--- 571,576 ----
                    if (!child_exited)
!                       waitret = waitpid(fpid, &waitstat, WNOHANG);
!                   if (!WIFEXITED(waitstat) && !WIFSIGNALED(waitstat)) {
                        kill(fpid, SIGTERM);
!                       waitret = waitpid(fpid, &waitstat, WNOHANG);
                    }
***************
*** 583,585 ****
                if (child_exited) {
!                   waitret = waitpid(fpid, &cst1, WNOHANG);
                    break;
--- 583,585 ----
                if (child_exited) {
!                   waitret = waitpid(fpid, &waitstat, WNOHANG);
                    break;
***************
*** 589,591 ****
                */
!               if ((waitret = waitpid(fpid, &cst1, WNOHANG)) > 0) {
                    /*
--- 589,591 ----
                */
!               if ((waitret = waitpid(fpid, &waitstat, WNOHANG)) > 0) {
                    /*
***************
*** 615,627 ****
                kill(fpid, SIGTERM);
!               waitret = waitpid(fpid, &cst1, WNOHANG);
            }
            if (waitret > 0) {
!               if (WIFEXITED(cst1)) {
                    CTRACE(tfp, "HTParseInet: NSL_FORK child %d exited, status 
0x%x.\n",
!                               (int)waitret, cst1);
!               } else if (WIFSIGNALED(cst1)) {
                    CTRACE(tfp, "HTParseInet: NSL_FORK child %d got signal, 
status 0x%x!\n",
!                               (int)waitret, cst1);
  #ifdef WCOREDUMP
!                   if (WCOREDUMP(cst1)) {
                        CTRACE(tfp, "HTParseInet: NSL_FORK child %d dumped 
core!\n",
--- 615,627 ----
                kill(fpid, SIGTERM);
!               waitret = waitpid(fpid, &waitstat, WNOHANG);
            }
            if (waitret > 0) {
!               if (WIFEXITED(waitstat)) {
                    CTRACE(tfp, "HTParseInet: NSL_FORK child %d exited, status 
0x%x.\n",
!                               (int)waitret, waitstat);
!               } else if (WIFSIGNALED(waitstat)) {
                    CTRACE(tfp, "HTParseInet: NSL_FORK child %d got signal, 
status 0x%x!\n",
!                               (int)waitret, waitstat);
  #ifdef WCOREDUMP
!                   if (WCOREDUMP(waitstat)) {
                        CTRACE(tfp, "HTParseInet: NSL_FORK child %d dumped 
core!\n",
***************
*** 630,634 ****
  #endif /* WCOREDUMP */
!               } else if (WIFSTOPPED(cst1)) {
                    CTRACE(tfp, "HTParseInet: NSL_FORK child %d is stopped, 
status 0x%x!\n",
!                               (int)waitret, cst1);
                }
--- 630,634 ----
  #endif /* WCOREDUMP */
!               } else if (WIFSTOPPED(waitstat)) {
                    CTRACE(tfp, "HTParseInet: NSL_FORK child %d is stopped, 
status 0x%x!\n",
!                               (int)waitret, waitstat);
                }

reply via email to

[Prev in Thread] Current Thread [Next in Thread]