You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by Dean Gaudet <dg...@hyperreal.com> on 1997/03/23 00:51:10 UTC
cvs commit: apache/src CHANGES alloc.c http_config.c http_log.c http_main.c mod_log_agent.c mod_log_config.c mod_log_referer.c mod_mime.c mod_rewrite.c util.c
dgaudet 97/03/22 15:51:10
Modified: src CHANGES alloc.c http_config.c http_log.c
http_main.c mod_log_agent.c mod_log_config.c
mod_log_referer.c mod_mime.c mod_rewrite.c util.c
Log:
errno reporting cleanup. popenf, pclosef, spawn_child all return valid errno.
Reviewed by: Chuck, Jim
Revision Changes Path
1.209 +5 -0 apache/src/CHANGES
Index: CHANGES
===================================================================
RCS file: /export/home/cvs/apache/src/CHANGES,v
retrieving revision 1.208
retrieving revision 1.209
diff -C3 -r1.208 -r1.209
*** CHANGES 1997/03/20 23:30:48 1.208
--- CHANGES 1997/03/22 23:51:00 1.209
***************
*** 1,5 ****
--- 1,10 ----
Changes with Apache 1.2b8
+ *) Report extra info from errno with many errors that cause httpd to exit.
+ spawn_child, popenf, and pclosef now have valid errno returns in the
+ event of an error. Correct problems where errno was stomped on
+ before being reported. [Dean Gaudet]
+
*) In the proxy, if the cache filesystem was full, garbage_coll() was
never called, and thus the filesystem would remain full indefinitely.
We now also remove incomplete cache files left if the origin server
1.25 +15 -0 apache/src/alloc.c
Index: alloc.c
===================================================================
RCS file: /export/home/cvs/apache/src/alloc.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -C3 -r1.24 -r1.25
*** alloc.c 1997/03/20 17:10:10 1.24
--- alloc.c 1997/03/22 23:51:01 1.25
***************
*** 791,812 ****
--- 791,818 ----
int popenf(pool *a, const char *name, int flg, int mode)
{
int fd;
+ int save_errno;
block_alarms();
fd = open(name, flg, mode);
+ save_errno = errno;
if (fd >= 0) note_cleanups_for_fd (a, fd);
unblock_alarms();
+ errno = save_errno;
return fd;
}
int pclosef(pool *a, int fd)
{
int res;
+ int save_errno;
block_alarms();
res = close(fd);
+ save_errno = errno;
kill_cleanup(a, (void *)fd, fd_cleanup);
unblock_alarms();
+ errno = save_errno;
return res;
}
***************
*** 927,950 ****
--- 933,962 ----
int in_fds[2];
int out_fds[2];
int err_fds[2];
+ int save_errno;
block_alarms();
if (pipe_in && pipe (in_fds) < 0)
{
+ save_errno = errno;
unblock_alarms();
+ errno = save_errno;
return 0;
}
if (pipe_out && pipe (out_fds) < 0) {
+ save_errno = errno;
if (pipe_in) {
close (in_fds[0]); close (in_fds[1]);
}
unblock_alarms();
+ errno = save_errno;
return 0;
}
if (pipe_err && pipe (err_fds) < 0) {
+ save_errno = errno;
if (pipe_in) {
close (in_fds[0]); close (in_fds[1]);
}
***************
*** 952,961 ****
--- 964,975 ----
close (out_fds[0]); close (out_fds[1]);
}
unblock_alarms();
+ errno = save_errno;
return 0;
}
if ((pid = fork()) < 0) {
+ save_errno = errno;
if (pipe_in) {
close (in_fds[0]); close (in_fds[1]);
}
***************
*** 966,971 ****
--- 980,986 ----
close (err_fds[0]); close (err_fds[1]);
}
unblock_alarms();
+ errno = save_errno;
return 0;
}
1.47 +4 -2 apache/src/http_config.c
Index: http_config.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_config.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -C3 -r1.46 -r1.47
*** http_config.c 1997/03/20 23:30:48 1.46
--- http_config.c 1997/03/22 23:51:01 1.47
***************
*** 759,767 ****
parms.override = (RSRC_CONF|OR_ALL)&~(OR_AUTHCFG|OR_LIMIT);
if(!(cfg = fopen(fname, "r"))) {
fprintf(stderr,"httpd: could not open document config file %s\n",
fname);
- perror("fopen");
exit(1);
}
--- 759,767 ----
parms.override = (RSRC_CONF|OR_ALL)&~(OR_AUTHCFG|OR_LIMIT);
if(!(cfg = fopen(fname, "r"))) {
+ perror("fopen");
fprintf(stderr,"httpd: could not open document config file %s\n",
fname);
exit(1);
}
***************
*** 931,938 ****
getrlimit ( RLIMIT_NOFILE, &limits );
if ( limits.rlim_cur < limits.rlim_max ) {
limits.rlim_cur += 2;
! if ( setrlimit ( RLIMIT_NOFILE, &limits ) < 0 )
fprintf (stderr, "Cannot exceed hard limit for open files");
}
#endif
--- 931,940 ----
getrlimit ( RLIMIT_NOFILE, &limits );
if ( limits.rlim_cur < limits.rlim_max ) {
limits.rlim_cur += 2;
! if ( setrlimit ( RLIMIT_NOFILE, &limits ) < 0 ) {
! perror ("setrlimit(RLIMIT_NOFILE)");
fprintf (stderr, "Cannot exceed hard limit for open files");
+ }
}
#endif
1.13 +6 -7 apache/src/http_log.c
Index: http_log.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_log.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C3 -r1.12 -r1.13
*** http_log.c 1997/01/10 09:34:41 1.12
--- http_log.c 1997/03/22 23:51:01 1.13
***************
*** 92,110 ****
if (*s->error_fname == '|') {
FILE *dummy;
! spawn_child(p, error_log_child, (void *)(s->error_fname+1),
! kill_after_timeout, &dummy, NULL);
!
! if (dummy == NULL) {
! fprintf (stderr, "Couldn't fork child for ErrorLog process\n");
! exit (1);
}
s->error_log = dummy;
} else {
if(!(s->error_log = pfopen(p, fname, "a"))) {
- fprintf(stderr,"httpd: could not open error log file %s.\n", fname);
perror("fopen");
exit(1);
}
}
--- 92,109 ----
if (*s->error_fname == '|') {
FILE *dummy;
! if (!spawn_child (p, error_log_child, (void *)(s->error_fname+1),
! kill_after_timeout, &dummy, NULL)) {
! perror ("spawn_child");
! fprintf (stderr, "Couldn't fork child for ErrorLog process\n");
! exit (1);
}
s->error_log = dummy;
} else {
if(!(s->error_log = pfopen(p, fname, "a"))) {
perror("fopen");
+ fprintf(stderr,"httpd: could not open error log file %s.\n", fname);
exit(1);
}
}
1.133 +10 -8 apache/src/http_main.c
Index: http_main.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_main.c,v
retrieving revision 1.132
retrieving revision 1.133
diff -C3 -r1.132 -r1.133
*** http_main.c 1997/03/20 23:30:49 1.132
--- http_main.c 1997/03/22 23:51:02 1.133
***************
*** 774,781 ****
#endif
if (scoreboard_fd == -1)
{
- fprintf (stderr, "Cannot open scoreboard file:\n");
perror (scoreboard_fname);
exit (1);
}
--- 774,781 ----
#endif
if (scoreboard_fd == -1)
{
perror (scoreboard_fname);
+ fprintf (stderr, "Cannot open scoreboard file:\n");
exit (1);
}
***************
*** 800,807 ****
#endif
if (scoreboard_fd == -1)
{
- fprintf (stderr, "Cannot open scoreboard file:\n");
perror (scoreboard_fname);
exit (1);
}
#else
--- 800,807 ----
#endif
if (scoreboard_fd == -1)
{
perror (scoreboard_fname);
+ fprintf (stderr, "Cannot open scoreboard file:\n");
exit (1);
}
#else
***************
*** 1192,1213 ****
if((x = fork()) > 0)
exit(0);
else if(x == -1) {
- fprintf(stderr,"httpd: unable to fork new process\n");
perror("fork");
exit(1);
}
#endif
#ifndef NO_SETSID
if((pgrp=setsid()) == -1) {
- fprintf(stderr,"httpd: setsid failed\n");
perror("setsid");
exit(1);
}
#else
#if defined(NEXT)
if(setpgrp(0,getpid()) == -1 || (pgrp = getpgrp(0)) == -1) {
- fprintf(stderr,"httpd: setpgrp or getpgrp failed\n");
perror("setpgrp");
exit(1);
}
#else
--- 1192,1213 ----
if((x = fork()) > 0)
exit(0);
else if(x == -1) {
perror("fork");
+ fprintf(stderr,"httpd: unable to fork new process\n");
exit(1);
}
#endif
#ifndef NO_SETSID
if((pgrp=setsid()) == -1) {
perror("setsid");
+ fprintf(stderr,"httpd: setsid failed\n");
exit(1);
}
#else
#if defined(NEXT)
if(setpgrp(0,getpid()) == -1 || (pgrp = getpgrp(0)) == -1) {
perror("setpgrp");
+ fprintf(stderr,"httpd: setpgrp or getpgrp failed\n");
exit(1);
}
#else
***************
*** 1216,1223 ****
pgrp=-getpid();
#else
if((pgrp=setpgrp(getpid(),0)) == -1) {
- fprintf(stderr,"httpd: setpgrp failed\n");
perror("setpgrp");
exit(1);
}
#endif
--- 1216,1223 ----
pgrp=-getpid();
#else
if((pgrp=setpgrp(getpid(),0)) == -1) {
perror("setpgrp");
+ fprintf(stderr,"httpd: setpgrp failed\n");
exit(1);
}
#endif
***************
*** 1570,1577 ****
int just_say_no = 1;
if (setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char*)&just_say_no,
! sizeof(int)) < 0)
fprintf(stderr, "httpd: could not set socket option TCP_NODELAY\n");
}
#else
#define sock_disable_nagle(s) /* NOOP */
--- 1570,1579 ----
int just_say_no = 1;
if (setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char*)&just_say_no,
! sizeof(int)) < 0) {
! perror ("setsockopt(TCP_NODELAY)");
fprintf(stderr, "httpd: could not set socket option TCP_NODELAY\n");
+ }
}
#else
#define sock_disable_nagle(s) /* NOOP */
***************
*** 1932,1941 ****
#endif
if(bind(s, (struct sockaddr *)server,sizeof(struct sockaddr_in)) == -1)
{
#ifdef MPE
if (ntohs(server->sin_port) < 1024) GETUSERMODE();
#endif
- perror("bind");
if (server->sin_addr.s_addr != htonl(INADDR_ANY))
fprintf(stderr,"httpd: could not bind to address %s port %d\n",
inet_ntoa(server->sin_addr), ntohs(server->sin_port));
--- 1934,1943 ----
#endif
if(bind(s, (struct sockaddr *)server,sizeof(struct sockaddr_in)) == -1)
{
+ perror("bind");
#ifdef MPE
if (ntohs(server->sin_port) < 1024) GETUSERMODE();
#endif
if (server->sin_addr.s_addr != htonl(INADDR_ANY))
fprintf(stderr,"httpd: could not bind to address %s port %d\n",
inet_ntoa(server->sin_addr), ntohs(server->sin_port));
1.11 +6 -5 apache/src/mod_log_agent.c
Index: mod_log_agent.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_log_agent.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C3 -r1.10 -r1.11
*** mod_log_agent.c 1997/03/07 14:15:42 1.10
--- mod_log_agent.c 1997/03/22 23:51:02 1.11
***************
*** 111,116 ****
--- 111,118 ----
#else
execl (SHELL_PATH, SHELL_PATH, "-c", (char *)cmd, NULL);
#endif
+ perror ("exec");
+ fprintf (stderr, "Exec of shell for logging failed!!!\n");
exit (1);
}
***************
*** 126,135 ****
if (*cls->fname == '|') {
FILE *dummy;
! spawn_child(p, agent_log_child, (void *)(cls->fname+1),
! kill_after_timeout, &dummy, NULL);
!
! if (dummy == NULL) {
fprintf (stderr, "Couldn't fork child for AgentLog process\n");
exit (1);
}
--- 128,136 ----
if (*cls->fname == '|') {
FILE *dummy;
! if (!spawn_child (p, agent_log_child, (void *)(cls->fname+1),
! kill_after_timeout, &dummy, NULL)) {
! perror ("spawn_child");
fprintf (stderr, "Couldn't fork child for AgentLog process\n");
exit (1);
}
***************
*** 138,145 ****
}
else if(*cls->fname != '\0') {
if((cls->agent_fd = popenf(p, fname, xfer_flags, xfer_mode)) < 0) {
- fprintf(stderr,"httpd: could not open agent log file %s.\n", fname);
perror("open");
exit(1);
}
}
--- 139,146 ----
}
else if(*cls->fname != '\0') {
if((cls->agent_fd = popenf(p, fname, xfer_flags, xfer_mode)) < 0) {
perror("open");
+ fprintf(stderr,"httpd: could not open agent log file %s.\n", fname);
exit(1);
}
}
1.26 +5 -5 apache/src/mod_log_config.c
Index: mod_log_config.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_log_config.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -C3 -r1.25 -r1.26
*** mod_log_config.c 1997/03/07 14:15:42 1.25
--- mod_log_config.c 1997/03/22 23:51:02 1.26
***************
*** 687,692 ****
--- 687,693 ----
#else
execl (SHELL_PATH, SHELL_PATH, "-c", (char *)cmd, NULL);
#endif
+ perror ("exec");
fprintf (stderr, "Exec of shell for logging failed!!!\n");
exit (1);
}
***************
*** 699,708 ****
if (*cls->fname == '|') {
FILE *dummy;
! spawn_child(p, config_log_child, (void *)(cls->fname+1),
! kill_after_timeout, &dummy, NULL);
!
! if (dummy == NULL) {
fprintf (stderr, "Couldn't fork child for TransferLog process\n");
exit (1);
}
--- 700,708 ----
if (*cls->fname == '|') {
FILE *dummy;
! if (!spawn_child (p, config_log_child, (void *)(cls->fname+1),
! kill_after_timeout, &dummy, NULL)) {
! perror ("spawn_child");
fprintf (stderr, "Couldn't fork child for TransferLog process\n");
exit (1);
}
***************
*** 712,720 ****
else {
char *fname = server_root_relative (p, cls->fname);
if((cls->log_fd = popenf(p, fname, xfer_flags, xfer_mode)) < 0) {
fprintf (stderr,
"httpd: could not open transfer log file %s.\n", fname);
- perror("open");
exit(1);
}
}
--- 712,720 ----
else {
char *fname = server_root_relative (p, cls->fname);
if((cls->log_fd = popenf(p, fname, xfer_flags, xfer_mode)) < 0) {
+ perror("open");
fprintf (stderr,
"httpd: could not open transfer log file %s.\n", fname);
exit(1);
}
}
1.11 +5 -5 apache/src/mod_log_referer.c
Index: mod_log_referer.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_log_referer.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C3 -r1.10 -r1.11
*** mod_log_referer.c 1997/03/07 14:15:42 1.10
--- mod_log_referer.c 1997/03/22 23:51:03 1.11
***************
*** 125,130 ****
--- 125,131 ----
#else
execl (SHELL_PATH, SHELL_PATH, "-c", (char *)cmd, NULL);
#endif
+ perror ("execl");
fprintf (stderr, "Exec of shell for logging failed!!!\n");
exit (1);
}
***************
*** 141,150 ****
if (*cls->fname == '|') {
FILE *dummy;
! spawn_child(p, referer_log_child, (void *)(cls->fname+1),
! kill_after_timeout, &dummy, NULL);
!
! if (dummy == NULL) {
fprintf (stderr, "Couldn't fork child for RefererLog process\n");
exit (1);
}
--- 142,150 ----
if (*cls->fname == '|') {
FILE *dummy;
! if (!spawn_child (p, referer_log_child, (void *)(cls->fname+1),
! kill_after_timeout, &dummy, NULL)) {
! perror ("spawn_child");
fprintf (stderr, "Couldn't fork child for RefererLog process\n");
exit (1);
}
***************
*** 153,160 ****
}
else if(*cls->fname != '\0') {
if((cls->referer_fd = popenf(p, fname, xfer_flags, xfer_mode)) < 0) {
- fprintf(stderr,"httpd: could not open referer log file %s.\n", fname);
perror("open");
exit(1);
}
}
--- 153,160 ----
}
else if(*cls->fname != '\0') {
if((cls->referer_fd = popenf(p, fname, xfer_flags, xfer_mode)) < 0) {
perror("open");
+ fprintf(stderr,"httpd: could not open referer log file %s.\n", fname);
exit(1);
}
}
1.17 +1 -1 apache/src/mod_mime.c
Index: mod_mime.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_mime.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C3 -r1.16 -r1.17
*** mod_mime.c 1997/03/07 14:15:42 1.16
--- mod_mime.c 1997/03/22 23:51:03 1.17
***************
*** 193,201 ****
types_confname = server_root_relative (p, types_confname);
if(!(f = fopen(types_confname,"r"))) {
fprintf(stderr,"httpd: could not open mime types file %s\n",
types_confname);
- perror("fopen");
exit(1);
}
--- 193,201 ----
types_confname = server_root_relative (p, types_confname);
if(!(f = fopen(types_confname,"r"))) {
+ perror("fopen");
fprintf(stderr,"httpd: could not open mime types file %s\n",
types_confname);
exit(1);
}
1.23 +7 -4 apache/src/mod_rewrite.c
Index: mod_rewrite.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_rewrite.c,v
retrieving revision 1.22
retrieving revision 1.23
diff -C3 -r1.22 -r1.23
*** mod_rewrite.c 1997/03/20 18:03:35 1.22
--- mod_rewrite.c 1997/03/22 23:51:03 1.23
***************
*** 2250,2258 ****
fname = server_root_relative(p, conf->rewritelogfile);
if (*conf->rewritelogfile == '|') {
! spawn_child(p, rewritelog_child, (void *)(conf->rewritelogfile+1),
! kill_after_timeout, &fp, NULL);
! if (fp == NULL) {
fprintf (stderr, "mod_rewrite: could not fork child for RewriteLog process\n");
exit (1);
}
--- 2250,2258 ----
fname = server_root_relative(p, conf->rewritelogfile);
if (*conf->rewritelogfile == '|') {
! if (!spawn_child (p, rewritelog_child, (void *)(conf->rewritelogfile+1),
! kill_after_timeout, &fp, NULL)) {
! perror ("spawn_child");
fprintf (stderr, "mod_rewrite: could not fork child for RewriteLog process\n");
exit (1);
}
***************
*** 2260,2267 ****
}
else if (*conf->rewritelogfile != '\0') {
if ((conf->rewritelogfp = popenf(p, fname, rewritelog_flags, rewritelog_mode)) < 0) {
- fprintf(stderr, "mod_rewrite: could not open RewriteLog file %s.\n", fname);
perror("open");
exit(1);
}
}
--- 2260,2267 ----
}
else if (*conf->rewritelogfile != '\0') {
if ((conf->rewritelogfp = popenf(p, fname, rewritelog_flags, rewritelog_mode)) < 0) {
perror("open");
+ fprintf(stderr, "mod_rewrite: could not open RewriteLog file %s.\n", fname);
exit(1);
}
}
***************
*** 2405,2410 ****
--- 2405,2411 ----
fpout = NULL;
rc = spawn_child(p, rewritemap_program_child, (void *)map->datafile, kill_after_timeout, &fpin, &fpout);
if (rc == 0 || fpin == NULL || fpout == NULL) {
+ perror ("spawn_child");
fprintf (stderr, "mod_rewrite: could not fork child for RewriteMap process\n");
exit (1);
}
***************
*** 3216,3221 ****
--- 3217,3223 ----
#endif
if (rc < 0) {
+ perror ("flock");
fprintf(stderr, "Error getting lock. Exiting!");
exit(1);
}
***************
*** 3240,3245 ****
--- 3242,3248 ----
#endif
if (rc < 0) {
+ perror ("flock");
fprintf(stderr, "Error freeing lock. Exiting!");
exit(1);
}
1.51 +1 -1 apache/src/util.c
Index: util.c
===================================================================
RCS file: /export/home/cvs/apache/src/util.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -C3 -r1.50 -r1.51
*** util.c 1997/03/20 17:10:09 1.50
--- util.c 1997/03/22 23:51:04 1.51
***************
*** 1129,1136 ****
len = sizeof(struct sockaddr);
if(getsockname(sd,&addr,&len) < 0) {
- fprintf (stderr, "Can't get local host address!\n");
perror ("getsockname");
exit(1);
}
--- 1129,1136 ----
len = sizeof(struct sockaddr);
if(getsockname(sd,&addr,&len) < 0) {
perror ("getsockname");
+ fprintf (stderr, "Can't get local host address!\n");
exit(1);
}