| Filename | /usr/libdata/perl5/OpenBSD/Temp.pm |
| Statements | Executed 39 statements in 952µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 373µs | 679µs | OpenBSD::Temp::BEGIN@23 |
| 1 | 1 | 1 | 94µs | 234µs | OpenBSD::Temp::file |
| 1 | 1 | 1 | 21µs | 140µs | OpenBSD::Temp::permanent_file |
| 1 | 1 | 1 | 19µs | 19µs | OpenBSD::Temp::reclaim |
| 1 | 1 | 1 | 16µs | 19µs | OpenBSD::PackageLocation::BEGIN@18 |
| 1 | 1 | 1 | 15µs | 15µs | OpenBSD::Temp::__ANON__[:39] |
| 1 | 1 | 1 | 12µs | 26µs | OpenBSD::Temp::END |
| 1 | 1 | 1 | 11µs | 76µs | OpenBSD::Temp::BEGIN@25 |
| 1 | 1 | 1 | 8µs | 16µs | OpenBSD::PackageLocation::BEGIN@19 |
| 1 | 1 | 1 | 7µs | 7µs | OpenBSD::Temp::BEGIN@24 |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::Temp::__ANON__[:49] |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::Temp::__ANON__[:70] |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::Temp::dir |
| 0 | 0 | 0 | 0s | 0s | OpenBSD::Temp::permanent_dir |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | # ex:ts=8 sw=4: | ||||
| 2 | # $OpenBSD: Temp.pm,v 1.27 2015/03/04 13:55:32 espie Exp $ | ||||
| 3 | # | ||||
| 4 | # Copyright (c) 2003-2005 Marc Espie <espie@openbsd.org> | ||||
| 5 | # | ||||
| 6 | # Permission to use, copy, modify, and distribute this software for any | ||||
| 7 | # purpose with or without fee is hereby granted, provided that the above | ||||
| 8 | # copyright notice and this permission notice appear in all copies. | ||||
| 9 | # | ||||
| 10 | # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||||
| 11 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||||
| 12 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||||
| 13 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||||
| 14 | # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||||
| 15 | # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||||
| 16 | # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||||
| 17 | |||||
| 18 | 2 | 25µs | 2 | 23µs | # spent 19µs (16+4) within OpenBSD::PackageLocation::BEGIN@18 which was called:
# once (16µs+4µs) by OpenBSD::PackageLocation::BEGIN@24 at line 18 # spent 19µs making 1 call to OpenBSD::PackageLocation::BEGIN@18
# spent 4µs making 1 call to strict::import |
| 19 | 2 | 31µs | 2 | 23µs | # spent 16µs (8+7) within OpenBSD::PackageLocation::BEGIN@19 which was called:
# once (8µs+7µs) by OpenBSD::PackageLocation::BEGIN@24 at line 19 # spent 16µs making 1 call to OpenBSD::PackageLocation::BEGIN@19
# spent 7µs making 1 call to warnings::import |
| 20 | |||||
| 21 | package OpenBSD::Temp; | ||||
| 22 | |||||
| 23 | 2 | 144µs | 2 | 718µs | # spent 679µs (373+306) within OpenBSD::Temp::BEGIN@23 which was called:
# once (373µs+306µs) by OpenBSD::PackageLocation::BEGIN@24 at line 23 # spent 679µs making 1 call to OpenBSD::Temp::BEGIN@23
# spent 40µs making 1 call to Exporter::import |
| 24 | 2 | 25µs | 1 | 7µs | # spent 7µs within OpenBSD::Temp::BEGIN@24 which was called:
# once (7µs+0s) by OpenBSD::PackageLocation::BEGIN@24 at line 24 # spent 7µs making 1 call to OpenBSD::Temp::BEGIN@24 |
| 25 | 2 | 541µs | 2 | 141µs | # spent 76µs (11+65) within OpenBSD::Temp::BEGIN@25 which was called:
# once (11µs+65µs) by OpenBSD::PackageLocation::BEGIN@24 at line 25 # spent 76µs making 1 call to OpenBSD::Temp::BEGIN@25
# spent 65µs making 1 call to Exporter::import |
| 26 | |||||
| 27 | 1 | 11µs | 1 | 2µs | our $tempbase = $ENV{'PKG_TMPDIR'} || OpenBSD::Paths->vartmp; # spent 2µs making 1 call to OpenBSD::Paths::vartmp |
| 28 | |||||
| 29 | 1 | 1µs | my $dirs = {}; | ||
| 30 | 1 | 800ns | my $files = {}; | ||
| 31 | |||||
| 32 | # spent 15µs within OpenBSD::Temp::__ANON__[/usr/libdata/perl5/OpenBSD/Temp.pm:39] which was called:
# once (15µs+0s) by OpenBSD::Temp::END at line 42 | ||||
| 33 | 1 | 9µs | while (my ($name, $pid) = each %$files) { | ||
| 34 | unlink($name) if $pid == $$; | ||||
| 35 | } | ||||
| 36 | 1 | 9µs | while (my ($dir, $pid) = each %$dirs) { | ||
| 37 | OpenBSD::Error->rmtree([$dir]) if $pid == $$; | ||||
| 38 | } | ||||
| 39 | 1 | 3µs | }; | ||
| 40 | |||||
| 41 | # spent 26µs (12+15) within OpenBSD::Temp::END which was called:
# once (12µs+15µs) by main::RUNTIME at line 0 of /usr/sbin/pkg_info | ||||
| 42 | 1 | 9µs | 1 | 15µs | &$cleanup; # spent 15µs making 1 call to OpenBSD::Temp::__ANON__[OpenBSD/Temp.pm:39] |
| 43 | } | ||||
| 44 | 1 | 5µs | 1 | 5µs | OpenBSD::Handler->register($cleanup); # spent 5µs making 1 call to OpenBSD::Handler::register |
| 45 | |||||
| 46 | sub dir | ||||
| 47 | { | ||||
| 48 | my $caught; | ||||
| 49 | my $h = sub { $caught = shift; }; | ||||
| 50 | my $dir; | ||||
| 51 | |||||
| 52 | { | ||||
| 53 | local $SIG{'INT'} = $h; | ||||
| 54 | local $SIG{'QUIT'} = $h; | ||||
| 55 | local $SIG{'HUP'} = $h; | ||||
| 56 | local $SIG{'KILL'} = $h; | ||||
| 57 | local $SIG{'TERM'} = $h; | ||||
| 58 | $dir = permanent_dir($tempbase, "pkginfo"); | ||||
| 59 | $dirs->{$dir} = $$; | ||||
| 60 | } | ||||
| 61 | if (defined $caught) { | ||||
| 62 | kill $caught, $$; | ||||
| 63 | } | ||||
| 64 | return "$dir/"; | ||||
| 65 | } | ||||
| 66 | |||||
| 67 | sub file | ||||
| 68 | # spent 234µs (94+140) within OpenBSD::Temp::file which was called:
# once (94µs+140µs) by OpenBSD::PackageRepository::HTTPorFTP::list at line 894 of OpenBSD/PackageRepository.pm | ||||
| 69 | 1 | 900ns | my $caught; | ||
| 70 | 1 | 11µs | my $h = sub { $caught = shift; }; | ||
| 71 | 1 | 900ns | my ($fh, $file); | ||
| 72 | |||||
| 73 | { | ||||
| 74 | 2 | 25µs | local $SIG{'INT'} = $h; | ||
| 75 | 1 | 3µs | local $SIG{'QUIT'} = $h; | ||
| 76 | 1 | 3µs | local $SIG{'HUP'} = $h; | ||
| 77 | 1 | 3µs | local $SIG{'KILL'} = $h; | ||
| 78 | 1 | 4µs | local $SIG{'TERM'} = $h; | ||
| 79 | 1 | 8µs | 1 | 140µs | ($fh, $file) = permanent_file($tempbase, "pkgout"); # spent 140µs making 1 call to OpenBSD::Temp::permanent_file |
| 80 | 1 | 22µs | if (defined $file) { | ||
| 81 | $files->{$file} = $$; | ||||
| 82 | } | ||||
| 83 | } | ||||
| 84 | 1 | 900ns | if (defined $caught) { | ||
| 85 | kill $caught, $$; | ||||
| 86 | } | ||||
| 87 | 1 | 17µs | return $file; | ||
| 88 | } | ||||
| 89 | |||||
| 90 | sub reclaim | ||||
| 91 | # spent 19µs within OpenBSD::Temp::reclaim which was called:
# once (19µs+0s) by OpenBSD::PackageRepository::parse_problems at line 359 of OpenBSD/PackageRepository.pm | ||||
| 92 | 1 | 2µs | my ($class, $name) = @_; | ||
| 93 | 1 | 7µs | delete $files->{$name}; | ||
| 94 | 1 | 7µs | delete $dirs->{$name}; | ||
| 95 | } | ||||
| 96 | |||||
| 97 | sub permanent_file | ||||
| 98 | # spent 140µs (21+120) within OpenBSD::Temp::permanent_file which was called:
# once (21µs+120µs) by OpenBSD::Temp::file at line 79 | ||||
| 99 | 1 | 3µs | my ($dir, $stem) = @_; | ||
| 100 | 1 | 2µs | my $template = "$stem.XXXXXXXXXX"; | ||
| 101 | 1 | 2µs | if (defined $dir) { | ||
| 102 | $template = "$dir/$template"; | ||||
| 103 | } | ||||
| 104 | 1 | 11µs | 1 | 120µs | return OpenBSD::MkTemp::mkstemp($template); # spent 120µs making 1 call to OpenBSD::MkTemp::mkstemp |
| 105 | } | ||||
| 106 | |||||
| 107 | sub permanent_dir | ||||
| 108 | { | ||||
| 109 | my ($dir, $stem) = @_; | ||||
| 110 | my $template = "$stem.XXXXXXXXXX"; | ||||
| 111 | if (defined $dir) { | ||||
| 112 | $template = "$dir/$template"; | ||||
| 113 | } | ||||
| 114 | return OpenBSD::MkTemp::mkdtemp($template); | ||||
| 115 | } | ||||
| 116 | |||||
| 117 | 1 | 6µs | 1; |