pike.git / src / modules / Gz / zlibmod.c

version» Context lines:

pike.git/src/modules/Gz/zlibmod.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: zlibmod.c,v 1.66 2004/03/19 14:36:24 nilsson Exp $ + || $Id: zlibmod.c,v 1.67 2009/08/28 13:30:53 mast Exp $   */      #include "global.h" - RCSID("$Id: zlibmod.c,v 1.66 2004/03/19 14:36:24 nilsson Exp $"); + RCSID("$Id: zlibmod.c,v 1.67 2009/08/28 13:30:53 mast Exp $");      #include "zlib_machine.h"   #include "module.h"      #if !defined(HAVE_LIBZ) && !defined(HAVE_LIBGZ)   #undef HAVE_ZLIB_H   #endif      #ifdef HAVE_ZLIB_H   
pike.git/src/modules/Gz/zlibmod.c:161:    break;       default:    if(THIS->gz.msg)    Pike_error("Failed to initialize gz_deflate: %s\n",THIS->gz.msg);    else    Pike_error("Failed to initialize gz_deflate\n");    }   }    + static void do_mt_unlock (PIKE_MUTEX_T *lock) + { +  mt_unlock (lock); + } +    static int do_deflate(dynamic_buffer *buf,    struct zipper *this,    int flush)   {    int ret=0; -  +  ONERROR uwp;       THREADS_ALLOW();    mt_lock(& this->lock);    THREADS_DISALLOW(); -  +  SET_ONERROR (uwp, do_mt_unlock, &this->lock); +     if(!this->gz.state)    ret=Z_STREAM_ERROR;    else    do    {    this->gz.next_out=(Bytef *)low_make_buf_space(    /* recommended by the zlib people */    (this->gz.avail_out =    this->gz.avail_in ?    this->gz.avail_in+this->gz.avail_in/1000+42 :
pike.git/src/modules/Gz/zlibmod.c:194:    ret=deflate(& this->gz, flush);    THREADS_DISALLOW();       /* Absorb any unused space /Hubbe */    low_make_buf_space(-((ptrdiff_t)this->gz.avail_out), buf);       if(ret == Z_BUF_ERROR) ret=Z_OK;    }    while (ret==Z_OK && (this->gz.avail_in || !this->gz.avail_out));    -  mt_unlock(& this->lock); +  CALL_AND_UNSET_ONERROR (uwp);    return ret;   }      /*! @decl string deflate(string data, int|void flush)    *!    *! This function performs gzip style compression on a string @[data] and    *! returns the packed data. Streaming can be done by calling this    *! function several times and concatenating the returned data.    *!    *! The optional argument @[flush] should be one of the following:
pike.git/src/modules/Gz/zlibmod.c:404:    else    Pike_error("Failed to initialize gz_inflate\n");    }   }      static int do_inflate(dynamic_buffer *buf,    struct zipper *this,    int flush)   {    int fail=0; +  ONERROR uwp; +     THREADS_ALLOW();    mt_lock(& this->lock);    THREADS_DISALLOW(); -  +  SET_ONERROR (uwp, do_mt_unlock, &this->lock); +     if(!this->gz.state)    {    fail=Z_STREAM_ERROR;    }else{   #if 0    static int fnord=0;    fnord++;   #endif       do
pike.git/src/modules/Gz/zlibmod.c:455:       if(ret == Z_BUF_ERROR) ret=Z_OK;       if(ret != Z_OK)    {    fail=ret;    break;    }    } while(!this->gz.avail_out || flush==Z_FINISH || this->gz.avail_in);    } -  mt_unlock(& this->lock); +  +  CALL_AND_UNSET_ONERROR (uwp);    return fail;   }      /*! @decl string inflate(string data)    *!    *! This function performs gzip style decompression. It can inflate    *! a whole file at once or in blocks.    *!    *! @example    *! // whole file