ignore errors of pipe read (can happen with shutdown now,

now that all fd's are closed neatly in vfs), change messaging
in unexpected restarts
This commit is contained in:
Ben Gras 2009-05-06 15:38:32 +00:00
parent fd7ef243e4
commit 8b72765e39

View file

@ -555,10 +555,7 @@ PUBLIC void do_exit(message *m_ptr)
r= read(exec_pipe[0], &slot_nr, sizeof(slot_nr)); r= read(exec_pipe[0], &slot_nr, sizeof(slot_nr));
if (r == -1) if (r == -1)
{ {
if (errno == -EAGAIN) /* Negative error defines */ break; /* No data */
break; /* No data */
panic("RS", "do_exit: read from exec pipe failed",
errno);
} }
if (r != sizeof(slot_nr)) if (r != sizeof(slot_nr))
{ {
@ -619,7 +616,6 @@ PUBLIC void do_exit(message *m_ptr)
rp->r_flags = 0; /* release slot */ rp->r_flags = 0; /* release slot */
} }
else { else {
printf("RS: unexpected exit. Restarting %s\n", rp->r_cmd);
/* Determine what to do. If this is the first unexpected /* Determine what to do. If this is the first unexpected
* exit, immediately restart this service. Otherwise use * exit, immediately restart this service. Otherwise use
* a binary exponetial backoff. * a binary exponetial backoff.
@ -637,15 +633,21 @@ rp->r_restarts= 0;
else else
rp->r_flags |= RS_CRASHED; rp->r_flags |= RS_CRASHED;
if (rp->r_script[0] != '\0') if (rp->r_script[0] != '\0') {
if(rs_verbose)
printf("RS: running restart script for %s\n",
rp->r_cmd);
run_script(rp); run_script(rp);
else if (rp->r_restarts > 0) { } else if (rp->r_restarts > 0) {
printf("RS: restarting %s, restarts %d\n",
rp->r_cmd, rp->r_backoff);
rp->r_backoff = 1 << MIN(rp->r_restarts,(BACKOFF_BITS-2)); rp->r_backoff = 1 << MIN(rp->r_restarts,(BACKOFF_BITS-2));
rp->r_backoff = MIN(rp->r_backoff,MAX_BACKOFF); rp->r_backoff = MIN(rp->r_backoff,MAX_BACKOFF);
if (rp->r_exec != NULL && rp->r_backoff > 1) if (rp->r_exec != NULL && rp->r_backoff > 1)
rp->r_backoff= 1; rp->r_backoff= 1;
} }
else { else {
printf("RS: restarting %s\n", rp->r_cmd);
start_service(rp, 0, &ep); /* direct restart */ start_service(rp, 0, &ep); /* direct restart */
m_ptr->RS_ENDPOINT = ep; m_ptr->RS_ENDPOINT = ep;
/* Do this even if no I/O happens with the ioctl, in /* Do this even if no I/O happens with the ioctl, in