Commit 80a3ee34 authored by David Johnson's avatar David Johnson

Make sure vnodePollCleanup is called if it exists.

(And fix it up for Docker...)
parent fd60aa4c
......@@ -1067,6 +1067,11 @@ sub CleanupVM()
}
}
# If we might have been polling, make sure that is cleaned up.
if (hasLibOp("vnodePollCleanup")) {
safeLibOp("vnodePollCleanup",1,0);
}
# if not halted, try that first
my ($ret,$err) = safeLibOp('vnodeState', 1, 0);
if ($err) {
......
......@@ -2649,12 +2649,13 @@ sub vnodePoll($$$$$$)
" --data-urlencode 'filters=\{\"type\":\[\"container\"\],".
" \"container\":\[\"${vnode_id}\"\]\}'".
" -G http:/events";
open($private->{DOCKER_EVENT_FD},"$ccmd |");
if ($?) {
my $pid = open($private->{DOCKER_EVENT_FD},"$ccmd |");
if (!defined($pid) || $?) {
warn("could not open docker socket for event stream for $vnode_id");
delete($private->{DOCKER_EVENT_HISTORY});
return -1;
}
$private->{DOCKER_EVENT_CHILD} = $pid;
$private->{DOCKER_EVENT_FD}->autoflush(1);
my $oldfh = select($private->{DOCKER_EVENT_FD});
$| = 1;
......@@ -2677,6 +2678,8 @@ sub vnodePoll($$$$$$)
TBDebugTimeStamp("lost docker event stream connection;".
" reconnecting...");
delete($private->{DOCKER_EVENT_FD});
kill('KILL',$private->{DOCKER_EVENT_CHILD});
delete($private->{DOCKER_EVENT_CHILD});
goto reconnect;
}
}
......@@ -2749,9 +2752,11 @@ sub vnodePollCleanup($$$$)
my ($vnode_id, $vmid, $vnconfig, $private) = @_;
if (exists($private->{DOCKER_EVENT_FD})) {
kill('KILL',$private->{DOCKER_EVENT_CHILD});
if ($private->{DOCKER_EVENT_FD}->opened()) {
close($private->{DOCKER_EVENT_FD});
}
delete($private->{DOCKER_EVENT_CHILD});
delete($private->{DOCKER_EVENT_FD});
}
if (exists($private->{DOCKER_EVENT_HISTORY})) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment