From 20b4b20c3df7fbede8ed99d6e13148c3f5719ec6 Mon Sep 17 00:00:00 2001 From: Francois Pons Date: Tue, 9 Jul 2002 15:06:11 +0000 Subject: 0.08-4mdk --- URPM.xs | 30 ++++++++++++++++++++++-------- URPM/Build.pm | 5 ++--- perl-URPM.spec | 5 ++++- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/URPM.xs b/URPM.xs index 6890bf3..a7165bc 100644 --- a/URPM.xs +++ b/URPM.xs @@ -613,13 +613,15 @@ update_header(char *filename, URPM__Package pkg, HV *provides, int packing) { Header header; int isSource; - if (rpmReadPackageHeader(fd, &header, &isSource, NULL, NULL) == 0) { + close(d); + if (fd != NULL && rpmReadPackageHeader(fd, &header, &isSource, NULL, NULL) == 0) { struct stat sb; char *basename; int_32 size; basename = strrchr(filename, '/'); fstat(fdFileno(fd), &sb); + fdClose(fd); size = sb.st_size; headerAddEntry(header, FILENAME_TAG, RPM_STRING_TYPE, basename != NULL ? basename + 1 : filename, 1); headerAddEntry(header, FILESIZE_TAG, RPM_INT32_TYPE, &size, 1); @@ -665,10 +667,14 @@ update_header(char *filename, URPM__Package pkg, HV *provides, int packing) { } else if (sig[0] == 0x8e && sig[1] == 0xad && sig[2] == 0xe8 && sig[3] == 0x01) { FD_t fd = fdDup(d); - if (pkg->h && !(pkg->flag & FLAG_NO_HEADER_FREE)) headerFree(pkg->h); - pkg->h = headerRead(fd, HEADER_MAGIC_YES); - pkg->flag &= ~FLAG_NO_HEADER_FREE; - return 1; + close(d); + if (fd != NULL) { + if (pkg->h && !(pkg->flag & FLAG_NO_HEADER_FREE)) headerFree(pkg->h); + pkg->h = headerRead(fd, HEADER_MAGIC_YES); + pkg->flag &= ~FLAG_NO_HEADER_FREE; + fdClose(fd); + return 1; + } } } } @@ -1384,6 +1390,13 @@ Pkg_update_header(pkg, filename) OUTPUT: RETVAL +void +Pkg_free_header(pkg) + URPM::Package pkg + CODE: + if (pkg->h && !(pkg->flag & FLAG_NO_HEADER_FREE)) headerFree(pkg->h); + pkg->h = NULL; + void Pkg_build_info(pkg, fileno, provides_files=NULL) URPM::Package pkg @@ -1429,9 +1442,10 @@ Pkg_build_header(pkg, fileno) if (pkg->h) { FD_t fd; - fd = fdDup(fileno); - headerWrite(fd, pkg->h, HEADER_MAGIC_YES); - fdClose(fd); + if ((fd = fdDup(fileno)) != NULL) { + headerWrite(fd, pkg->h, HEADER_MAGIC_YES); + fdClose(fd); + } else croak("unable to get rpmio handle on fileno %d", fileno); } else croak("no header available for package"); int diff --git a/URPM/Build.pm b/URPM/Build.pm index 9e60c02..e3029f7 100644 --- a/URPM/Build.pm +++ b/URPM/Build.pm @@ -12,6 +12,7 @@ use strict; sub parse_rpms_build_headers { my ($urpm, %options) = @_; my ($dir, %cache, @headers, %names); + local (*DIR, *F); #- check for mandatory options. if (@{$options{rpms} || []} > 0) { @@ -23,7 +24,6 @@ sub parse_rpms_build_headers { #- examine cache if it contains any headers which will be much faster to read #- than parsing rpm file directly. unless ($options{clean}) { - local *DIR; opendir DIR, $dir; while (my $file = readdir DIR) { $file =~ /(.+?-[^:\-]+-[^:\-]+\.[^:\-\.]+)(?::(\S+))?$/ or next; @@ -53,8 +53,7 @@ sub parse_rpms_build_headers { print STDERR "$dir/$filename\n"; unless (-s "$dir/$filename") { - local *F; - open F, ">$dir/$filename"; + open F, ">$dir/$filename" or die "unable to open $dir/$filename for writing\n"; $pkg->build_header(fileno *F); close F; } diff --git a/perl-URPM.spec b/perl-URPM.spec index 403125d..c189506 100644 --- a/perl-URPM.spec +++ b/perl-URPM.spec @@ -1,7 +1,7 @@ %define name perl-URPM %define real_name URPM %define version 0.08 -%define release 3mdk +%define release 4mdk %{expand:%%define rpm_version %(rpm -q --queryformat '%{VERSION}-%{RELEASE}' rpm)} @@ -48,6 +48,9 @@ rm -rf $RPM_BUILD_ROOT %changelog +* Tue Jul 9 2002 François Pons 0.08-4mdk +- fixed too many opened files when building hdlist. + * Tue Jul 9 2002 Pixel 0.08-3mdk - rebuild for perl 5.8.0 -- cgit v1.2.1