Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Projets publics
Ravada-Mirror
Commits
daa66c40
Commit
daa66c40
authored
Sep 23, 2016
by
Francesc Guasch
Browse files
fork when creating domains
parent
8df5a1c2
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/Ravada.pm
View file @
daa66c40
...
...
@@ -7,6 +7,7 @@ use Carp qw(carp croak);
use
Data::
Dumper
;
use
DBIx::
Connector
;
use
Moose
;
use
POSIX
qw(WNOHANG)
;
use
YAML
;
use
Ravada::
Auth
;
...
...
@@ -494,7 +495,7 @@ sub _cmd_domdisplay {
}
sub
_cmd_create
{
sub
_cmd_create
_fork
{
my
$self
=
shift
;
my
$request
=
shift
;
...
...
@@ -508,6 +509,52 @@ sub _cmd_create {
}
sub
_wait_pids
{
my
$self
=
shift
;
my
$request
=
shift
;
for
my
$pid
(
keys
%
{
$self
->
{
pids
}})
{
$request
->
status
("
waiting for pid
$pid
");
warn
"
Checking for pid '
$pid
' created at
"
.
localtime
(
$self
->
{
pids
}
->
{
$pid
});
my
$kid
=
waitpid
(
$pid
,
0
);
warn
"
Found
$kid
";
return
if
$kid
==
$pid
;
}
}
sub
_add_pid
{
my
$self
=
shift
;
my
$pid
=
shift
;
$self
->
{
pids
}
->
{
$pid
}
=
time
;
}
sub
_cmd_create
{
my
$self
=
shift
;
my
$request
=
shift
;
$request
->
status
('
waiting for other tasks
');
$self
->
_wait_pids
(
$request
);
$request
->
status
('
forking
');
my
$pid
=
fork
();
if
(
!
defined
$pid
)
{
$request
->
status
('
done
');
$request
->
error
("
I can't fork
");
return
;
}
if
(
$pid
==
0
)
{
$self
->
_cmd_create_fork
(
$request
);
exit
;
}
$self
->
_add_pid
(
$pid
);
return
;
}
sub
_cmd_remove
{
my
$self
=
shift
;
my
$request
=
shift
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment