1
0
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:
Ruben S. Montero 2020-04-22 20:45:12 +02:00
parent 206e2e7988
commit bc37f1aadc
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87
2 changed files with 18 additions and 10 deletions

View File

@ -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);
};
}
/* -------------------------------------------------------------------------- */

View File

@ -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