Boost logo

Boost :

From: berserker_r (berserker_r_at_[hidden])
Date: 2006-11-15 09:07:39


> What OS are you using? Is the session's work CPU bound?

I'm on Windows XP, sry but I can't understand what you mean with the
second question...
Just take your sample in "server.cpp": I need to be able to change the
code (in the session or server object, dunno where...) so that the server
is always free to accept (and process) a new connections even if there are
one or more active sessions taking a very long time to generate and send
theirs response.
For example:

void Session::handle_read(const asio::error_code& err, size_t length)
{
      --op_count_;

      if (!err)
      {
        read_data_length_ = length;
        ++unsent_count_;
        if (unsent_count_ == 1)
        {
          very_very_long_operation(); // Process the client request

          op_count_ += 2;
          std::swap(read_data_, write_data_);
          async_write(socket_, buffer(write_data_, read_data_length_),
              strand_.wrap(
                boost::bind(&session::handle_write, this,
placeholders::error)));
          socket_.async_read_some(buffer(read_data_, block_size_),
              strand_.wrap(
                boost::bind(&session::handle_read, this,
placeholders::error,
                  placeholders::bytes_transferred)));
        }
      }

      if (op_count_ == 0)
          io_service_.post(boost::bind(&session::destroy, this));
}

Session::very_very_long_operation() takes a lot of time :) I need in the
meanwhile to be able in the server to accept new connections, how can I do
that? I tried calling ios.run() from multiple threads as the documentation
said but the server is always locked until the session's operation is
completed...

P.S.: be patient plz my english is not very good :)


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk