You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by Roy Fielding <fi...@hyperreal.com> on 1997/01/25 21:12:52 UTC
cvs commit: apache/src CHANGES http_main.c
fielding 97/01/25 12:12:51
Modified: src CHANGES http_main.c
Log:
<ad...@virginia.edu> notified us of a problem with children for the httpd
dump core on SIGSEGV regularly, HPUX, version: 10.10, Apache 1.2b4.
Ben mentioned that the symptoms looked like a stack corruption.
I think this is being caused when an initial call to select or accept
fails (for any reason) and the code attempts to reuse the same parameters
even though they were modified by the call. In any case, we should be
reinitializing the parameters before each call even if this isn't the
cause of the problem. Also removes potential infinite loop in call to accept.
Reviewed by: Marc Slemko, Chuck Murcko, Randy Terbush
Revision Changes Path
1.132 +4 -0 apache/src/CHANGES
Index: CHANGES
===================================================================
RCS file: /export/home/cvs/apache/src/CHANGES,v
retrieving revision 1.131
retrieving revision 1.132
diff -C3 -r1.131 -r1.132
*** CHANGES 1997/01/25 15:37:23 1.131
--- CHANGES 1997/01/25 20:12:48 1.132
***************
*** 102,107 ****
--- 102,111 ----
*) Fixed initialization of parameter structure for sigaction.
[mgyger@itr.ch, Adrian Filipi-Martin]
+ *) Fixed reinitializing the parameters before each call to accept and
+ select, and removed potential for infinite loop in accept.
+ [Roy Fielding, after useful PR from adrian@virginia.edu]
+
Changes with Apache 1.2b4:
*) Fix possible race condition in accept_mutex_init() that
1.111 +22 -20 apache/src/http_main.c
Index: http_main.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_main.c,v
retrieving revision 1.110
retrieving revision 1.111
diff -C3 -r1.110 -r1.111
*** http_main.c 1997/01/24 21:06:33 1.110
--- http_main.c 1997/01/25 20:12:49 1.111
***************
*** 1576,1582 ****
exit(0);
}
- clen=sizeof(sa_client);
(void)update_child_status (child_num, SERVER_READY, (request_rec*)NULL);
accept_mutex_on(); /* Lock around "accept", if necessary */
--- 1576,1581 ----
***************
*** 1592,1598 ****
#else
csd = select(listenmaxfd+1, &fds, NULL, NULL, NULL);
#endif
! if (csd == -1 && errno != EINTR)
log_unixerr("select",NULL,"select error", server_conf);
/*fprintf(stderr,"%d check(2a) %d %d\n",getpid(),scoreboard_image->global.exit_generation,generation);*/
--- 1591,1597 ----
#else
csd = select(listenmaxfd+1, &fds, NULL, NULL, NULL);
#endif
! if (csd < 0 && errno != EINTR)
log_unixerr("select",NULL,"select error", server_conf);
/*fprintf(stderr,"%d check(2a) %d %d\n",getpid(),scoreboard_image->global.exit_generation,generation);*/
***************
*** 1604,1644 ****
if (FD_ISSET(sd, &fds)) break;
if (sd < 0) continue;
! clen=sizeof(sa_client);
! do csd=accept(sd, &sa_client, &clen);
! while (csd == -1 && errno == EINTR);
! if (csd != -1) break;
log_unixerr("accept", "(client socket)", NULL, server_conf);
}
! } else
! {
fd_set fds;
! memset(&fds,0,sizeof fds);
! FD_SET(sd,&fds);
!
! do
#ifdef HPUX
csd = select(sd+1, (int*)&fds, NULL, NULL, NULL);
#else
csd = select(sd+1, &fds, NULL, NULL, NULL);
#endif
! while(csd < 0 && errno == EINTR);
! if(csd < 0)
! {
log_unixerr("select","(listen)",NULL,server_conf);
exit(0);
! }
/*fprintf(stderr,"%d check(2a) %d %d\n",getpid(),scoreboard_image->global.exit_generation,generation);*/
sync_scoreboard_image();
if(scoreboard_image->global.exit_generation >= generation)
exit(0);
! while ((csd=accept(sd, &sa_client, &clen)) == -1)
! if (errno != EINTR)
! log_unixerr("accept",NULL,"socket error: accept failed", server_conf);
! }
accept_mutex_off(); /* unlock after "accept" */
--- 1603,1646 ----
if (FD_ISSET(sd, &fds)) break;
if (sd < 0) continue;
! do {
! clen = sizeof(sa_client);
! csd = accept(sd, &sa_client, &clen);
! } while (csd < 0 && errno == EINTR);
! if (csd < 0) break;
log_unixerr("accept", "(client socket)", NULL, server_conf);
}
! }
! else {
fd_set fds;
! do {
! FD_ZERO(&fds);
! FD_SET(sd,&fds);
#ifdef HPUX
csd = select(sd+1, (int*)&fds, NULL, NULL, NULL);
#else
csd = select(sd+1, &fds, NULL, NULL, NULL);
#endif
! } while (csd < 0 && errno == EINTR);
! if (csd < 0) {
log_unixerr("select","(listen)",NULL,server_conf);
exit(0);
! }
/*fprintf(stderr,"%d check(2a) %d %d\n",getpid(),scoreboard_image->global.exit_generation,generation);*/
sync_scoreboard_image();
if(scoreboard_image->global.exit_generation >= generation)
exit(0);
! do {
! clen = sizeof(sa_client);
! csd = accept(sd, &sa_client, &clen);
! } while (csd < 0 && errno == EINTR);
! if (csd < 0)
! log_unixerr("accept", NULL, "socket error: accept failed",
! server_conf);
! }
accept_mutex_off(); /* unlock after "accept" */