Below are snippet of my filters and stream.  I have also tried with 1.42 without any success.  Also, I have noticed the stream fail bit setting correctly upon exception but not exception itself.

Multichar content recognition filter

////////////////////////////////////////////////////////////////

        class content_recognition_filter: public multichar_dual_use_filter
        {
        public:
            content_recognition_filter():
            multichar_dual_use_filter(),
                eof_reached(false),
                read_header(false)
            { }
            template <typename Source>
            std::streamsize read(Source & src, char * buf, std::streamsize n)
            {
                unsigned int count = 0;
                if(eof_reached)
                    return -1;
                if(!read_header)
                {
                    // read the header, if error occurs throw exception
                    if(!special_read_header(src))
                    {
                        eof_reched = true;
                        read_header = true;
                        throw BOOST_IOSTREAMS_FAILURE("unknown data");
                    }
                }
                int c = 0;
            while(
                count < n &&
                !((c = boost::iostreams::get(src)) != EOF || (c != WOULD_BLOCK))
                )
                {
                    buf[count++] = c;
                }
                if(c==EOF)
                    eof_reached = true;
                return count == 0 && c != WOULD_BLOCK ? -1 : static_cast<streamsize>(count);
            }

////////////////////////////////////////////////////////////////
Stream that uses above filter with other filters.

#include "content_recognition_filter.hpp"

        class my_stream
            : public boost::iostreams::filtering_ostream
        {
           my_stream(const std::string & path)
{
  push(boost::iostreams::unix2dos_stdio_filter());
// my filter
  push(content_recognition_filter());
            push(boost::iostreams::file_source(path, std::ios_base::binary));
            if(!is_open())
                setstate(std::ios::badbit);
}
        }

////////////////////////////////////////////////////////////////
#include <iostream>
#include "mystream.h"
using namespace std;
int main()
{
  my_stream("file_name");
  try
{
  int c =0;
  while( (c = my_stream.get()) != EOF)
}
catch(...)
{
  cout<<"Caught an exception"<<endl;
  return -1;
}
return 0;
}

I am interested in knowing why behavior is different on two different platforms. Do I need to enable some preprocesser or need to do anything special on the Windows side to propagate exception to the user code.

-Anand




On Wed, Feb 24, 2010 at 1:01 PM, eg <egoots@gmail.com> wrote:
On 2/24/2010 8:18 AM, Anand Patel wrote:
I came across interesting exception propagation behavior across
different platform (win32, linux).  I have created several filters and
custom filtering stream with my filters (boost 1.38-1.41).  My filter
throws BOOST_IOSTREAMS_FAILURE("some message"); whenever error condition
occurs.  On Linux exception gets propagated all the way to user using my
stream.  On Windows XP (VS 2008) it gets caught somewhere in boost
framework or Windows.  Moreover,  after exception is silently caught and
dropped, all the filters close method is called.  This is where I run
into issue.
Is there anyway to ensure that upon exception no more data processing
takes place withing filtering_stream and its chain?


I could be wrong, but I am not sure if anyone can really help without seeing some sample code.

In any case, you may wish to try your tests again using boost 1.42 if only because there were some exception related fixes that made it into the iostreams library in this version.

For details on the iostreams fixes in this release, see:
http://www.boost.org/doc/libs/1_42_0/libs/iostreams/doc/release_notes.html





_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users