diff --git a/gstlal/configure.ac b/gstlal/configure.ac index 0de216acf4a9914c6ad49ce69215ba24655f11da..4ddde8b5b6e19c932dde5149dbe5ae9e9ed2b0fc 100644 --- a/gstlal/configure.ac +++ b/gstlal/configure.ac @@ -372,6 +372,17 @@ AC_SUBST([ORC_CFLAGS]) AC_SUBST([ORC_LIBS]) +# +# Check for zlib +# + + +AX_CHECK_ZLIB() +if test x$HAVE_LIBZ = "xno" ; then + AC_MSG_FAILURE([zlib is required]) +fi + + # # Output configure information # diff --git a/gstlal/debian/control.in b/gstlal/debian/control.in index a7b3234106f30958a3756e2f79bc2139d9199dff..2d7b65b390796ec073ac774ddc0e7b27b2d2c5fd 100644 --- a/gstlal/debian/control.in +++ b/gstlal/debian/control.in @@ -28,7 +28,8 @@ Build-Depends: pkg-config, python-all-dev (>= @MIN_PYTHON_VERSION@), python-gi-dev (>= @MIN_PYGOBJECT_VERSION@), - python-numpy-dev + python-numpy-dev, + zlib1g-dev Package: gstlal Architecture: any @@ -65,7 +66,8 @@ Depends: ${shlibs:Depends}, ${misc:Depends}, ${python:Depends}, python-ligo-lw (>= @MIN_LIGO_LW_VERSION@), python-ligo-segments (>= @MIN_LIGO_SEGMENTS_VERSION@), python-numpy, - python-scipy + python-scipy, + zlib1g # FIXME: gstreamer1.0-python3-plugin-loader is *in fact* a dependency, but # it's not possible to have both our own legacy plugin loader and the stock # loader installed in the gstreamer search path simultaneously, so we have @@ -97,7 +99,8 @@ Depends: ${shlibs:Depends}, ${misc:Depends}, libgsl-dev (>= 1.9), libgstreamer-plugins-base1.0-dev (>= @MIN_GSTREAMER_VERSION@), libgstreamer1.0-dev (>= @MIN_GSTREAMER_VERSION@), - python-all-dev (>= @MIN_PYTHON_VERSION@) + python-all-dev (>= @MIN_PYTHON_VERSION@), + zlib1g-dev Description: Files and documentation needed for compiling gstlal based plugins and programs. This package contains the files needed for building gstlal-based plugins and programs. diff --git a/gstlal/gstlal.spec.in b/gstlal/gstlal.spec.in index 288c6fe2cf1783923c3f32332868b85a21969d1b..0a4c139fe1ef43d940b32a92a28dc99a3390f538 100644 --- a/gstlal/gstlal.spec.in +++ b/gstlal/gstlal.spec.in @@ -36,6 +36,7 @@ Requires: python >= @MIN_PYTHON_VERSION@ Requires: python-%{gstreamername} Requires: python-gobject >= @MIN_PYGOBJECT_VERSION@ Requires: scipy +Requires: zlib BuildRequires: doxygen >= @MIN_DOXYGEN_VERSION@ BuildRequires: fftw-devel >= 3 BuildRequires: gobject-introspection-devel >= @MIN_GOBJECT_INTROSPECTION_VERSION@ @@ -57,6 +58,7 @@ BuildRequires: orc >= @MIN_ORC_VERSION@ BuildRequires: python-devel >= @MIN_PYTHON_VERSION@ # needed for gstpythonplugin.c remove when we remove that plugin from gstlal BuildRequires: pygobject3-devel >= @MIN_PYGOBJECT_VERSION@ +BuildRequires: zlib-devel Source: @PACKAGE_NAME@-%{version}.tar.gz URL: https://wiki.ligo.org/DASWG/GstLAL Packager: Kipp Cannon <kipp.cannon@ligo.org> diff --git a/gstlal/lib/gstlal/ezxml.c b/gstlal/lib/gstlal/ezxml.c index 3e993c50e531311f99bdca600deeea65a4219722..200d3d294924036153b5c842aa339d123afbb69b 100644 --- a/gstlal/lib/gstlal/ezxml.c +++ b/gstlal/lib/gstlal/ezxml.c @@ -33,6 +33,7 @@ #include <sys/mman.h> #endif // EZXML_NOMMAP #include <sys/stat.h> +#include <zlib.h> #include "ezxml.h" #define EZXML_WS "\t\r\n " // whitespace @@ -632,29 +633,46 @@ ezxml_t ezxml_parse_fp(FILE *fp) ezxml_t ezxml_parse_fd(int fd) { ezxml_root_t root; - struct stat st; - size_t l; - void *m; + gzFile gzf; + int fd_dup; + size_t l = 0; + void *m = NULL; if (fd < 0) return NULL; - fstat(fd, &st); -#ifndef EZXML_NOMMAP - l = (st.st_size + sysconf(_SC_PAGESIZE) - 1) & ~(sysconf(_SC_PAGESIZE) -1); - if ((m = mmap(NULL, l, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0)) != - MAP_FAILED) { - madvise(m, l, MADV_SEQUENTIAL); // optimize for sequential access - root = (ezxml_root_t)ezxml_parse_str(m, st.st_size); - madvise(m, root->len = l, MADV_NORMAL); // put it back to normal + fd_dup = dup(fd); + if(fd_dup < 0) + return NULL; + gzf = gzdopen(fd_dup, "rb"); + if(!gzf) { + close(fd_dup); + return NULL; } - else { // mmap failed, read file into memory -#endif // EZXML_NOMMAP - l = read(fd, m = malloc(st.st_size), st.st_size); - root = (ezxml_root_t)ezxml_parse_str(m, l); - root->len = -1; // so we know to free s in ezxml_free() -#ifndef EZXML_NOMMAP - } -#endif // EZXML_NOMMAP + + do { + int n; + void *m_new = realloc(m, l + 8192); + if(!m_new) { + gzclose(gzf); + free(m); + return NULL; + } + m = m_new; + n = gzread(gzf, m + l, 8192); + if(n < 0) { + gzclose(gzf); + free(m); + return NULL; + } + l += n; + if(n < 8192) + break; + } while(1); + + gzclose(gzf); + + root = (ezxml_root_t)ezxml_parse_str(m, l); + root->len = -1; // so we know to free s in ezxml_free() return &root->xml; }