[Linux-ha-dev] Heartbeat 0.45 experiences
Alan Robertson
alanr@bell-labs.com
Mon, 18 Oct 1999 20:15:50 -0600
Steve Beattie wrote:
>
> Hi Alan, ha-developers,
>
> I toyed around with 0.45 release last week, and thought I would report
> my results. Mostly, I am very happy with it; however, I did run into a
> few snags of varying seriousness.
>
> 1. "/etc/rc.d/init.d/heartbeat restart" only stops heartbeat, it does
> not actually restart it.
I think I fixed this in my CVS instance at cvs.linux-ha.org. I put in code to
delay exiting from a heartbeat -k until the heartbeat process it's trying to
stop actually exits and disappears from the process table. This is probably
what was causing your problem. I've seen it do that. The code from the
alarm(0)...do...while... is the fix. Here's the new code:
/*
* We've been asked to shut down the currently running heartbeat
* process
*/
if (killrunninghb) {
if (running_hb_pid < 0) {
fprintf(stderr, "ERROR: Heartbeat not currently
running.\n");
cleanexit(1);
}
if (kill(running_hb_pid, SIGTERM) >= 0) {
/* Wait for the running heartbeat to die */
alarm(0);
do {
sleep(1);
}while (kill(running_hb_pid, 0) >= 0);
cleanexit(0);
}
fprintf(stderr, "ERROR: Could not kill pid %d", running_hb_pid);
perror(" ");
cleanexit(1);
}
Thanks for the report!
-- Alan Robertson
alanr@bell-labs.com