www-apache-bugdb mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@ihgp.ih.lucent.com
Subject Re: os-other/2320: Support of UTS 2.1.2 is broken
Date Fri, 05 Jun 1998 20:10:01 GMT
The following reply was made to PR os-other/2320; it has been noted by GNATS.

From: dwd@ihgp.ih.lucent.com
To: Dean Gaudet <dgaudet@arctic.org>
Cc: apbugs@hyperreal.org
Subject: Re: os-other/2320: Support of UTS 2.1.2 is broken
Date: Fri, 5 Jun 1998 14:58:57 -0500

 On Jun 4,  1:36pm, Dean Gaudet wrote:
 > Hey, could you do us a huge favour... in a few hours, go to
 > ftp://dev.apache.org/from-cvs/ and grab a snapshot.  It has a tweak that
 > someone else gave us to get NEXTSTEP to compile.  That tweak introduced a
 > #define ap_wait_t, which you could use to do the NEED_UNION_WAIT thing
 > you've got in this patch... Could you update your patch?
 > 
 > Thanks
 > Dean
 
 I have now integrated with snapshot apache_19980606010034.  The patches
 are below.  I eliminated NEED_UNION_WAIT.
 
 I discovered that I had accidentally left out src/main/util_script.c.  
 It is included below now. 
 
 Thanks for your quick response.
 
 - Dave Dykstra
 
 
 *** src/Configure.O	Fri Jun  5 11:11:22 1998
 --- src/Configure	Fri Jun  5 11:12:59 1998
 ***************
 *** 629,636 ****
   	;;
       *-uts*)
   	OS='Amdahl UTS'
 ! 	CFLAGS="$CFLAGS -Xa -eft -DUTS21"
   	LIBS="$LIBS -lsocket -lbsd -la"
   	;;
       *-ultrix)
   	OS='ULTRIX'
 --- 629,637 ----
   	;;
       *-uts*)
   	OS='Amdahl UTS'
 ! 	CFLAGS="$CFLAGS -Xa -eft -DUTS21 -DUSEBCOPY"
   	LIBS="$LIBS -lsocket -lbsd -la"
 + 	DEF_WANTHSREGEX=yes
   	;;
       *-ultrix)
   	OS='ULTRIX'
 *** src/include/conf.h.O	Fri Jun  5 11:25:15 1998
 --- src/include/conf.h	Fri Jun  5 11:56:10 1998
 ***************
 *** 573,585 ****
   #undef NO_KILLPG
   #define NO_SETSID
   #define NEED_WAITPID
 - #define NO_OTHER_CHILD
   #define STDIN_FILENO 0
   #define STDOUT_FILENO 1
   #define STDERR_FILENO 2
   #define HAVE_SYSLOG 1
   #define strftime(buf,bufsize,fmt,tm)    ascftime(buf,fmt,tm)
   #include <sys/types.h>
   
   #elif defined(APOLLO)
   #undef HAVE_GMTOFF
 --- 573,596 ----
   #undef NO_KILLPG
   #define NO_SETSID
   #define NEED_WAITPID
   #define STDIN_FILENO 0
   #define STDOUT_FILENO 1
   #define STDERR_FILENO 2
   #define HAVE_SYSLOG 1
 + #define USE_LONGJMP
 + #define JMP_BUF jmp_buf
 + #define NO_USE_SIGACTION
 + #define NEED_STRERROR
 + #define NEED_STRSTR
 + #define NEED_POUND_BANG
 + #define NDELAYPIPERETURNSZERO
 + #define NO_DATA NO_ADDRESS
 + #define	ap_wait_t		union wait
 + #define WEXITSTATUS(status)	(int)((status).w_retcode)
 + #define WTERMSIG(status)	(int)((status).w_termsig)
   #define strftime(buf,bufsize,fmt,tm)    ascftime(buf,fmt,tm)
   #include <sys/types.h>
 + #include <sys/time.h>     
   
   #elif defined(APOLLO)
   #undef HAVE_GMTOFF
 *** src/main/http_main.c.O	Fri Jun  5 11:18:48 1998
 --- src/main/http_main.c	Fri Jun  5 15:34:18 1998
 ***************
 *** 2129,2157 ****
   }
   
   
 ! #if defined(BROKEN_WAIT) || defined(NEED_WAITPID)
   /*
 !    Some systems appear to fail to deliver dead children to wait() at times.
 !    This sorts them out. In fact, this may have been caused by a race condition
 !    in wait_or_timeout(). But this routine is still useful for systems with no
 !    waitpid().
    */
 ! int reap_children(void)
   {
 !     int status, n;
 !     int ret = 0;
   
       for (n = 0; n < max_daemons_limit; ++n) {
 ! 	if (ap_scoreboard_image->servers[n].status != SERVER_DEAD
 ! 	    && waitpid(ap_scoreboard_image->parent[n].pid, &status, WNOHANG)
 ! 	    == -1
 ! 	    && errno == ECHILD) {
 ! 	    ap_sync_scoreboard_image();
   	    ap_update_child_status(n, SERVER_DEAD, NULL);
 ! 	    ret = 1;
   	}
       }
 !     return ret;
   }
   #endif
   
 --- 2129,2154 ----
   }
   
   
 ! #if defined(NEED_WAITPID)
   /*
 !    Systems without a real waitpid sometimes lose a child's exit while waiting
 !    for another.  Search through the scoreboard for missing children.
    */
 ! int reap_children(ap_wait_t *status)
   {
 !     int n, pid;
   
       for (n = 0; n < max_daemons_limit; ++n) {
 !         ap_sync_scoreboard_image();
 ! 	if (ap_scoreboard_image->servers[n].status != SERVER_DEAD &&
 ! 		kill((pid = ap_scoreboard_image->parent[n].pid), 0) == -1) {
   	    ap_update_child_status(n, SERVER_DEAD, NULL);
 ! 	    /* just mark it as having a successful exit status */
 ! 	    *status = 0; 
 ! 	    return(pid);
   	}
       }
 !     return 0;
   }
   #endif
   
 ***************
 *** 2214,2219 ****
 --- 2211,2221 ----
       if (ret > 0) {
   	return ret;
       }
 + #ifdef NEED_WAITPID
 +     if ((ret = reap_children(status)) > 0) {
 + 	return ret;
 +     }
 + #endif
       tv.tv_sec = SCOREBOARD_MAINTENANCE_INTERVAL / 1000000;
       tv.tv_usec = SCOREBOARD_MAINTENANCE_INTERVAL % 1000000;
       ap_select(0, NULL, NULL, NULL, &tv);
 *** src/main/http_protocol.c.O	Fri Jun  5 11:15:29 1998
 --- src/main/http_protocol.c	Fri Jun  5 11:16:12 1998
 ***************
 *** 1721,1726 ****
 --- 1721,1735 ----
   
       FD_ZERO(&fds);
       while (!r->connection->aborted) {
 + #ifdef NDELAYPIPERETURNSZERO
 + 	/* Contributed by dwd@bell-labs.com for UTS 2.1.2, where the fcntl */
 + 	/*   O_NDELAY flag causes read to return 0 when there's nothing */
 + 	/*   available when reading from a pipe.  That makes it tricky */
 + 	/*   to detect end-of-file :-(.  This stupid bug is even documented */
 + 	/*   in the read(2) man page where it says that everything but */
 + 	/*   pipes return -1 and EAGAIN.  That makes it a feature, right? */
 + 	int afterselect = 0;
 + #endif
           if ((length > 0) && (total_bytes_sent + IOBUFSIZE) > length)
               len = length - total_bytes_sent;
           else
 ***************
 *** 1728,1735 ****
   
           do {
               n = ap_bread(fb, buf, len);
 !             if (n >= 0 || r->connection->aborted)
                   break;
               if (n < 0 && errno != EAGAIN)
                   break;
               /* we need to block, so flush the output first */
 --- 1737,1751 ----
   
           do {
               n = ap_bread(fb, buf, len);
 ! #ifdef NDELAYPIPERETURNSZERO
 ! 	    if ((n > 0) || (n == 0 && afterselect))
 ! 		break;
 ! #else
 !             if (n >= 0)
                   break;
 + #endif
 +             if (r->connection->aborted)
 +                 break;
               if (n < 0 && errno != EAGAIN)
                   break;
               /* we need to block, so flush the output first */
 ***************
 *** 1742,1747 ****
 --- 1758,1766 ----
                * around and try another read
                */
               ap_select(fd + 1, &fds, NULL, NULL, NULL);
 + #ifdef NDELAYPIPERETURNSZERO
 + 	    afterselect = 1;
 + #endif
           } while (!r->connection->aborted);
   
           if (n < 1 || r->connection->aborted) {
 *** src/main/util.c.O	Fri Jun  5 11:18:09 1998
 --- src/main/util.c	Fri Jun  5 11:18:25 1998
 ***************
 *** 1397,1403 ****
   }
   #endif
   
 ! 
   
   #ifdef NEED_INITGROUPS
   int initgroups(const char *name, gid_t basegid)
 --- 1397,1431 ----
   }
   #endif
   
 ! /* The following routine was donated for UTS21 by dwd@bell-labs.com */
 ! #ifdef NEED_STRSTR
 ! char *strstr(char *s1, char *s2)
 ! {
 !     char *p1, *p2;
 !     if (*s2 == '\0') {
 ! 	/* an empty s2 */
 !         return(s1);
 !     }
 !     while((s1 = strchr(s1, *s2)) != NULL) {
 ! 	/* found first character of s2, see if the rest matches */
 !         p1 = s1;
 !         p2 = s2;
 !         while (*++p1 == *++p2) {
 !             if (*p1 == '\0') {
 !                 /* both strings ended together */
 !                 return(s1);
 !             }
 !         }
 !         if (*p2 == '\0') {
 !             /* second string ended, a match */
 !             break;
 !         }
 ! 	/* didn't find a match here, try starting at next character in s1 */
 !         s1++;
 !     }
 !     return(s1);
 ! }
 ! #endif
   
   #ifdef NEED_INITGROUPS
   int initgroups(const char *name, gid_t basegid)
 ***************
 *** 1433,1439 ****
   #ifdef NEED_WAITPID
   /* From ikluft@amdahl.com
    * this is not ideal but it works for SVR3 variants
 !  * httpd does not use the options so this doesn't implement them
    */
   int waitpid(pid_t pid, int *statusp, int options)
   {
 --- 1461,1468 ----
   #ifdef NEED_WAITPID
   /* From ikluft@amdahl.com
    * this is not ideal but it works for SVR3 variants
 !  * Modified by dwd@bell-labs.com to call wait3 instead of wait because
 !  *   apache started to use the WNOHANG option.
    */
   int waitpid(pid_t pid, int *statusp, int options)
   {
 ***************
 *** 1442,1448 ****
   	errno = ECHILD;
   	return -1;
       }
 !     while (((tmp_pid = wait(statusp)) != pid) && (tmp_pid != -1));
       return tmp_pid;
   }
   #endif
 --- 1471,1479 ----
   	errno = ECHILD;
   	return -1;
       }
 !     while (((tmp_pid = wait3(statusp, options, 0)) != pid) &&
 ! 		(tmp_pid != -1) && (tmp_pid != 0) && (pid != -1))
 ! 	;
       return tmp_pid;
   }
   #endif
 *** src/main/util_script.c.O	Fri Jun  5 15:40:52 1998
 --- src/main/util_script.c	Fri Jun  5 15:41:15 1998
 ***************
 *** 999,1014 ****
   	}
       }
       else {
 ! 	if (shellcmd)
 ! 	    execle(SHELL_PATH, SHELL_PATH, "-c", argv0, NULL, env);
   
 ! 	else if ((!r->args) || (!r->args[0]) || strchr(r->args, '='))
   	    execle(r->filename, argv0, NULL, env);
   
 ! 	else
   	    execve(r->filename,
 ! 		   create_argv(r->pool, NULL, NULL, NULL, argv0, r->args),
 ! 		   env);
       }
       return (pid);
   #endif
 --- 999,1051 ----
   	}
       }
       else {
 ! #ifdef NEED_POUND_BANG
 ! 	/* This was donated for UTS21 by Dave Dykstra */
 ! 	/* #! is not supported by the OS, so do it ourselves */
 ! 	int fd, n;
 ! 	char bangbuf[256], *eol;
 ! 
 ! 	if (!shellcmd) {
 ! 	    if ((fd = open(r->filename, O_RDONLY)) > 0) {
 ! 		n = read(fd, bangbuf, sizeof(bangbuf)-1);
 ! 		close(fd);
 ! 		if ((n > 2) && (bangbuf[0] == '#') && (bangbuf[1] == '!')) {
 ! 		    bangbuf[sizeof(bangbuf)-1] = '\0';
 ! 		    if ((eol = strchr(&bangbuf[2], '\n')) != NULL) {
 ! 			*eol = '\0';
 ! 		    }
 ! 		}
 ! 		else
 ! 		    bangbuf[0] = '\0';
 ! 	    }
 ! 	}
 ! #endif
   
 ! 	if (shellcmd) 
 ! 	    execle(SHELL_PATH, SHELL_PATH, "-c", argv0, NULL, env);
 ! 	
 ! 	else if ((!r->args) || (!r->args[0]) || strchr(r->args, '=')) {
 ! #ifdef NEED_POUND_BANG
 ! 	    if (bangbuf[0] != '\0')
 ! 		execle(&bangbuf[2], argv0, r->filename, NULL, env);
 ! 	    else
 ! #endif
   	    execle(r->filename, argv0, NULL, env);
   
 ! 	}
 ! 	else {
 ! #ifdef NEED_POUND_BANG
 ! 	    if (bangbuf[0] != '\0')
 ! 		execve(&bangbuf[2],
 ! 		       create_argv(r->pool, argv0, NULL, NULL,
 ! 						r->filename, r->args),
 ! 		       env);
 ! 	    else
 ! #endif
   	    execve(r->filename,
 ! 	           create_argv(r->pool, NULL, NULL, NULL, argv0, r->args),
 ! 	           env);
 ! 	}
       }
       return (pid);
   #endif

Mime
View raw message