}
if (is_graceful) {
- int i, bytes_to_write;
+ int i;
char char_of_death = '!';
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, server_conf,
}
}
/* give the children the signal to die */
- /* XXX - This while loop logic should be made into a utility function */
- bytes_to_write = num_daemons;
- while (bytes_to_write > 0) {
- i = write(pipe_of_death[1], &char_of_death, bytes_to_write);
- if (i == -1) {
+ for (i = 0; i < num_daemons;) {
+ if (write(pipe_of_death[1], &char_of_death, 1) == -1) {
if (errno == EINTR) continue;
- ap_log_error(APLOG_MARK, APLOG_ERR, server_conf,
- "write pipe_of_death");
- break;
+ ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "write pipe_of_death");
}
- bytes_to_write -= i;
+ i++;
}
}
else {
update_scoreboard_global();
if (is_graceful) {
- int i, j, bytes_to_write;
+ int i, j;
char char_of_death = '!';
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_NOTICE, server_conf,
"SIGWINCH received. Doing graceful restart");
- /* give the children the signal to die. Sending more bytes than
- * children is okay, because the pipe is recreated for every
- * generation */
- /* XXX - This while loop logic should be made into a utility function */
- bytes_to_write = ap_daemons_limit;
- while (bytes_to_write > 0) {
- i = write(pipe_of_death[1], &char_of_death, bytes_to_write);
- if (i == -1) {
+ /* give the children the signal to die */
+ for (i = 0; i < ap_daemons_limit;) {
+ if (write(pipe_of_death[1], &char_of_death, 1) == -1) {
if (errno == EINTR) continue;
- ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf,
- "write pipe_of_death");
- break;
+ ap_log_error(APLOG_MARK, APLOG_WARNING, server_conf, "write pipe_of_death");
}
- bytes_to_write -= i;
+ i++;
}
/* This is mostly for debugging... so that we know what is still