mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-16 22:50:10 +03:00
M #-: Kill drivers after grace period
This commit is contained in:
parent
206e2e7988
commit
bc37f1aadc
@ -34,9 +34,8 @@
|
||||
|
||||
Mad::~Mad()
|
||||
{
|
||||
char buf[]="FINALIZE\n";
|
||||
int status;
|
||||
pid_t rp;
|
||||
char buf[] = "FINALIZE\n";
|
||||
bool success = false;
|
||||
|
||||
if ( pid==-1)
|
||||
{
|
||||
@ -49,13 +48,23 @@ Mad::~Mad()
|
||||
close(mad_nebula_pipe);
|
||||
close(nebula_mad_pipe);
|
||||
|
||||
rp = waitpid(pid, &status, WNOHANG);
|
||||
|
||||
if ( rp == 0 )
|
||||
for (int i=0; i < 2; ++i)
|
||||
{
|
||||
int status;
|
||||
|
||||
if ( waitpid(pid, &status, WNOHANG) != 0 )
|
||||
{
|
||||
success = true;
|
||||
break;
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
waitpid(pid, &status, WNOHANG);
|
||||
}
|
||||
|
||||
if (!success)
|
||||
{
|
||||
kill(pid, SIGKILL);
|
||||
};
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -140,9 +140,8 @@ class OpenNebulaDriver < ActionManager
|
||||
# Start the driver. Reads from STDIN and executes methods associated with
|
||||
# the messages
|
||||
def start_driver
|
||||
loop_thread = Thread.new { loop }
|
||||
Thread.new { loop }
|
||||
start_listener
|
||||
loop_thread.kill
|
||||
end
|
||||
|
||||
# This function parses a string with this form:
|
||||
@ -187,7 +186,7 @@ class OpenNebulaDriver < ActionManager
|
||||
|
||||
def loop
|
||||
Kernel.loop do
|
||||
exit(-1) if STDIN.eof?
|
||||
exit!(-1) if STDIN.eof?
|
||||
|
||||
str = STDIN.gets
|
||||
next unless str
|
||||
|
Loading…
x
Reference in New Issue
Block a user