diff options
author | Francois Pons <fpons@mandriva.com> | 2002-01-17 12:01:54 +0000 |
---|---|---|
committer | Francois Pons <fpons@mandriva.com> | 2002-01-17 12:01:54 +0000 |
commit | 362a3293bf2f2da458dce726e1c4281533464784 (patch) | |
tree | bc6eab9070ca931bbeb36763995dcc8112a93af4 | |
parent | 492b556e340f2722ad860950ed0245e5ea9335ba (diff) | |
download | rpmtools-362a3293bf2f2da458dce726e1c4281533464784.tar rpmtools-362a3293bf2f2da458dce726e1c4281533464784.tar.gz rpmtools-362a3293bf2f2da458dce726e1c4281533464784.tar.bz2 rpmtools-362a3293bf2f2da458dce726e1c4281533464784.tar.xz rpmtools-362a3293bf2f2da458dce726e1c4281533464784.zip |
4.0-7mdk4.0.7
-rw-r--r-- | parsehdlist.c | 25 | ||||
-rw-r--r-- | rpmtools.spec | 6 | ||||
-rw-r--r-- | rpmtools.xs | 41 |
3 files changed, 48 insertions, 24 deletions
diff --git a/parsehdlist.c b/parsehdlist.c index 16137eb..88c9235 100644 --- a/parsehdlist.c +++ b/parsehdlist.c @@ -1,7 +1,10 @@ +#include <sys/select.h> +#include <sys/time.h> #include <sys/types.h> #include <sys/wait.h> #include <sys/stat.h> #include <fcntl.h> +#include <unistd.h> #include <signal.h> #include <errno.h> #include <rpm/rpmlib.h> @@ -314,6 +317,15 @@ int main(int argc, char **argv) int fdno[2]; if (!pipe(fdno)) { if ((pid = fork()) != 0) { + fd_set readfds; + struct timeval timeout; + + FD_ZERO(&readfds); + FD_SET(fdno[0], &readfds); + timeout.tv_sec = 1; + timeout.tv_usec = 0; + select(fdno[0]+1, &readfds, NULL, NULL, &timeout); + fd = fdDup(fdno[0]); close(fdno[0]); close(fdno[1]); @@ -376,7 +388,17 @@ int main(int argc, char **argv) long count = 0; /* fprintf(stderr, "parsehdlist: reading %s\n", argv[i]); */ - while ((header=headerRead(fd, HEADER_MAGIC_YES))) { + while (count < 20 && (header=headerRead(fd, HEADER_MAGIC_YES)) == 0) { + struct timeval timeout; + + timeout.tv_sec = 0; + timeout.tv_usec = 10000; + select(0, NULL, NULL, NULL, &timeout); + + ++count; + } + count = 0; + while (header != 0) { char *name = get_name(header, RPMTAG_NAME); ++count; @@ -413,6 +435,7 @@ int main(int argc, char **argv) } headerFree(header); } + header=headerRead(fd, HEADER_MAGIC_YES); } if (!count) exit(3); /* no package is an error */ } diff --git a/rpmtools.spec b/rpmtools.spec index 82ad4b4..3b56637 100644 --- a/rpmtools.spec +++ b/rpmtools.spec @@ -1,5 +1,5 @@ %define name rpmtools -%define release 6mdk +%define release 7mdk # do not modify here, see Makefile in the CVS %define version 4.0 @@ -54,6 +54,10 @@ rm -rf $RPM_BUILD_ROOT %{_libdir}/perl5/man/*/* %changelog +* Thu Jan 17 2002 François Pons <fpons@mandrakesoft.com> 4.0-7mdk +- added safe guard delay to ensure data is available. +- updated parsehdlist with such above feature. + * Thu Jan 17 2002 François Pons <fpons@mandrakesoft.com> 4.0-6mdk - modified delay management in respect to rpmlib, use select to wait for input before giving up to rpmlib. diff --git a/rpmtools.xs b/rpmtools.xs index e73998d..975ad89 100644 --- a/rpmtools.xs +++ b/rpmtools.xs @@ -522,9 +522,21 @@ _parse_(fileno_or_rpmfile, flag, info, ...) /* start the big loop, parse all header from fileno, then extract information to store into iinfo and iprovides. */ - while (fd_is_hdlist >= 0 ? (fd_is_hdlist > 0 ? - ((header=headerRead(fd, HEADER_MAGIC_YES)) != 0) : - ((fd_is_hdlist = -1), rpmReadPackageHeader(fd, &header, &i, NULL, NULL) == 0)) : 0) { + if (fd_is_hdlist) { + while (fd_is_hdlist < 20 && (header=headerRead(fd, HEADER_MAGIC_YES)) == 0) { + struct timeval timeout; + + timeout.tv_sec = 0; + timeout.tv_usec = 10000; + select(0, NULL, NULL, NULL, &timeout); + + ++fd_is_hdlist; + } + } else { + if (rpmReadPackageHeader(fd, &header, &i, NULL, NULL) != 0) + header = 0; + } + while (header != 0) { SV *fullname_sv = get_fullname_sv(header); HV* header_info = get_info(header, bflag, iprovides); @@ -533,28 +545,13 @@ _parse_(fileno_or_rpmfile, flag, info, ...) /* return fullname on stack */ EXTEND(SP, 1); PUSHs(sv_2mortal(fullname_sv)); -#if 0 - char *name = get_name(header, RPMTAG_NAME); - char *version = get_name(header, RPMTAG_VERSION); - char *release = get_name(header, RPMTAG_RELEASE); - char *arch = get_name(header, RPMTAG_ARCH); - char *fullname = (char*)alloca(strlen(name)+strlen(version)+strlen(release)+strlen(arch)+4); - STRLEN fullname_len = sprintf(fullname, "%s-%s-%s.%s", name, version, release, arch); - HV* header_info = get_info(header, bflag, iprovides); - - /* once the hash header_info is built, store a reference to it - in iinfo. - note sv_name is not incremented here, it has the default value of before. */ - /* hv_store(iinfo, name, strlen(name), newRV_noinc((SV*)header_info), 0); */ - hv_store(iinfo, fullname, fullname_len, newRV_noinc((SV*)header_info), 0); - - /* return fullname on stack */ - EXTEND(SP, 1); - PUSHs(sv_2mortal(newSVpv(fullname, fullname_len))); -#endif /* dispose of some memory */ headerFree(header); + + /* continue loop for hdlist */ + if (fd_is_hdlist) + header=headerRead(fd, HEADER_MAGIC_YES); } fdClose(fd); } else croak("bad arguments list"); |