Changeset cc27c86


Ignore:
Timestamp:
01/09/12 14:20:33 (9 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
a0ec6f1
Parents:
a566d9c3
Message:
  • Fixed bug where a zlib writer was not being flushed correctly during zlib_wclose(). The problem was that we were not handling the case where Z_BUF_ERROR is returned by the final deflate() call, instead jumping straight to closing as though we had gotten a Z_STREAM_END.

This should fix that annoying problem where the occasionaly trace file written by libtrace reports "Truncated packet" when being read back in.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/iow-zlib.c

    r8608a0fa rcc27c86  
    4040#include <stdlib.h>
    4141#include <string.h>
     42#include <assert.h>
    4243
    4344/* Libtrace IO module implementing a zlib writer */
     
    142143static void zlib_wclose(iow_t *iow)
    143144{
    144         while (deflate(&DATA(iow)->strm, Z_FINISH) == Z_OK) {
    145                 /* Need to flush the output buffer */
     145        int res;
     146       
     147        while (1) {
     148                res = deflate(&DATA(iow)->strm, Z_FINISH);
     149
     150                if (res == Z_STREAM_END)
     151                        break;
     152                if (res == Z_STREAM_ERROR) {
     153                        fprintf(stderr, "Z_STREAM_ERROR while closing output\n");
     154                        break;
     155                }
     156       
    146157                wandio_wwrite(DATA(iow)->child,
    147158                                (char*)DATA(iow)->outbuff,
     
    150161                DATA(iow)->strm.avail_out = sizeof(DATA(iow)->outbuff);
    151162        }
     163
    152164        deflateEnd(&DATA(iow)->strm);
    153165        wandio_wwrite(DATA(iow)->child,
Note: See TracChangeset for help on using the changeset viewer.