Author: spadkins
Date: Tue Nov 16 07:31:49 2010
New Revision: 14524
Modified:
p5ee/trunk/App-Context/lib/App/Context.pm
Log:
enhance the DESTROY method to fix a bug with profiling
Modified: p5ee/trunk/App-Context/lib/App/Context.pm
==============================================================================
--- p5ee/trunk/App-Context/lib/App/Context.pm (original)
+++ p5ee/trunk/App-Context/lib/App/Context.pm Tue Nov 16 07:31:49 2010
@@ -2785,11 +2785,14 @@
&App::sub_entry if ($App::trace);
my ($self) = @_;
my $pid = fork();
- if (!$pid) { # in the child process
+ if (!defined $pid) { # in the parent process. fork() failed (usually due
to insufficient resources).
+ $self->log({level=>1},"Child process failed to start (fork() returned
undef).\n");
+ }
+ elsif ($pid == 0) { # in the child process
# $self->{is_child} = 1; # I might need to add this sometime, but
not now
$self->shutdown_unshareable_resources();
}
- else {
+ else { # in the parent process. fork() succeeded. the $pid
is the process id of the child process.
$self->log({level=>4},"Child $pid started.\n");
}
&App::sub_exit($pid) if ($App::trace);
@@ -3075,6 +3078,8 @@
&App::sub_entry if ($App::trace);
my ($self, $end_cd) = @_;
+ return if ($self->{profiler_log_finished});
+
$end_cd ||= "F"; # assume we finish using normal
processing
my $profile_state = $self->{profile_state};
my $profile_stats = $self->profile_stats();
@@ -3155,6 +3160,7 @@
$run_db_time, $num_db_calls, $num_db_rows_read,
$num_db_rows_write, $run_file_time, $run_net_time, $num_net_calls,
@aux_values, $run_other_time, $run_xfer_time, $content_length);
}
+ $self->{profiler_log_finished} = 1;
&App::sub_exit() if ($App::trace);
}