Boost logo

Boost Users :

From: Christian Henning (chhenning_at_[hidden])
Date: 2006-10-30 09:49:31


On 10/30/06, Christopher Kohlhoff <chris_at_[hidden]> wrote:
> Hi Christian,
>
> Christian Henning wrote:
> > Hi Christopher, thanks for putting so much time into this
> > issue. I changed the code as you requested, namely I added a
> > new members to my connection class.
>
> I found another similar problem in image_source::do_write().
> I've just implemented a feature for the next version that uses
> MSVC's iterator debugging to check the buffer validity. These
> program bugs show up as an assertion failure when this new
> "buffer debugging" feature is enabled.
>
I did make the change to all my source classes. A do_write operation
now looks like this:

   void do_write()
   {
      int i = 9;

      std::ostringstream archive_stream;
      boost::archive::binary_oarchive archive( archive_stream );
      archive & i;

      _outbound_data = archive_stream.str();

      std::ostringstream header_stream;
      header_stream << std::setw( 8 )
                     << std::hex
                     << _outbound_data.size();

      _outbound_header = header_stream.str();

      std::vector<boost::asio::const_buffer> buffers;
      buffers.push_back(boost::asio::buffer( _outbound_header ));
      buffers.push_back(boost::asio::buffer( _outbound_data ));

      boost::asio::async_write( _socket
                              , buffers
                              , boost::bind( &image_quality_source::handle_write
                                           , this
                                           ,
boost::asio::placeholders::error ));
   }

Both the _outbound_heaser and _outbound_data are members of the class.
> > But unfortunately nothing has changed. I still have memory
> > leaks reported. Did you do the change on your machine?
>
> I have now, and I found what I think is the cause of the leak.
> Can you please try the following change to
> asio/detail/win_iocp_io_service.hpp:
>
> @@ -74,10 +74,11 @@
> DWORD_PTR completion_key = 0;
> #endif
> LPOVERLAPPED overlapped = 0;
> - ::GetQueuedCompletionStatus(iocp_.handle,
> + ::SetLastError(0);
> + BOOL ok = ::GetQueuedCompletionStatus(iocp_.handle,
> &bytes_transferred, &completion_key, &overlapped, 0);
> DWORD last_error = ::GetLastError();
> - if (last_error == WAIT_TIMEOUT)
> + if (!ok && overlapped == 0 && last_error == WAIT_TIMEOUT)
> break;
> if (overlapped)
> static_cast<operation*>(overlapped)->destroy();
>

This is most likely offtopic, but how do apply that patch to a source
file? Have never done that. Is there a program I should use?

Thanks Christian


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net