bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Persistence Engine flush issue and fixes for cppunit tests.


From: Chad Yates
Subject: Persistence Engine flush issue and fixes for cppunit tests.
Date: Mon, 12 Jul 2004 00:41:10 -0700

I have finally gotten a chance to look at some projects that use commoncpp2,
and in doing so I have figured out a few problems with the persistence
engine, and got the cppunit test suite working on Linux (I originally was
developing only on Win32 when I wrote it).

The problem with the persistent engine creating 0 byte files in the  tests
is do to the fact that when zlib is compiled into the persistence code, the
internal zlib buffer is not flushed completely until the Engine is
destructed.  this poses a problem for the test suite because I close the
archive stream before reading back the data.  since this is done in the same
scope the Engine does not fall out of scope before the archive closes.  The
buffers never get written to disk.  with zlib disabled this problem is not
evident as the data goes straight to the file.  I have introduced a
Engine::flush() method to expose this, but perhaps there is a better way?

Below is a synopsis of what I have changed to bring things back in line.
After some discussion, specifically about flush(), I can provide patches to
1.2.3 or can attempt to apply them to the most current cvs code.

persist.h/engine.cpp:
- Added support for serializing std:strings back in.  was removed when the
  switch to support ost::String was made.  was this Inadvertent?
- Added flush method that flushes the zlib buffers.  This allows you to
explicitly
  flush things before closing the output stream.  This was being handled by
the
  Engine destructor before, now the Destructor calls flush(), but only if
the
  underlying stream is still good().
- Added header dependencies of exception.h and config.h in so that persist.h
  could be used included standalone.
- static_cast necessary to resolve ambiguity in use of std::string vs.
ost::string
  for writing out persistence Id's

Test_Engine.cpp:
  - Commented out int64/uint64 primitive tests in the Persistence tests as
they
    were giving errors, need to investigate further
  - Added explicit calls to new Engine::flush() function before closing down
the
    output archive stream(s).

Test_Date.h:
  - changed expected values to match new style for string 'YYYY-MM-DD' vs.
value
    'YYYYMMDD'.
  - removed using namespace ost statement

Test_TCPStream:
  - commented out isPending test as it is hanging the test suite. looks like
    something changed recently to cause it as my 1.2.0rc1 version doesn't.
What is
    the timeout measured in for the TCPStream constructor and the isPending
    function supposed to be anyway? the doxygen docs don't seem to say.

Test_UrlString.h:
  - Now includes url.h instead of urlstring.h  (Must have been combined at
some point).
  - adjusted for changes to ost::String usage

Thanks,

Chad





reply via email to

[Prev in Thread] Current Thread [Next in Thread]