Esempio n. 1
0
void Connection::handleReadBody(ReplyPtr reply,
				const asio_error_code& e,
				std::size_t bytes_transferred)
{
  LOG_DEBUG(socket().native() << ": handleReadBody(): " << e.message());

  if (disconnectCallback_) {
    if (e && e != asio::error::operation_aborted) {
      boost::function<void()> f = disconnectCallback_;
      disconnectCallback_ = boost::function<void()>();
      f();
    } else if (e != asio::error::operation_aborted) {
      LOG_ERROR(socket().native()
		<< ": handleReadBody(): while waiting for disconnect, "
		"unexpected error code: " << e.message());
      close();
    }

    return;
  }

  cancelReadTimer();

  if (!e) {
    rcv_remaining_ = rcv_buffers_.back().data();
    rcv_buffer_size_ = bytes_transferred;
    handleReadBody(reply);
  } else if (e != asio::error::operation_aborted
	     && e != asio::error::bad_descriptor) {
    reply->consumeData(rcv_remaining_, rcv_remaining_, Request::Error);
    handleError(e);
  }
}
Esempio n. 2
0
void SslConnection::handleHandshake(const asio_error_code& error)
{
  SSL* ssl = 0;
#if BOOST_VERSION >= 104700
  ssl = socket_.native_handle();
#else //BOOST_VERSION < 104700
  if(socket_.impl())
    ssl = socket_.impl()->ssl;
#endif //BOOST_VERSION >= 104700

  if (!error) {
    Connection::start();
    // ssl handle must be registered after calling start(), since start()
    // resets the structs
    registerSslHandle(ssl);
  } else {
    long sslState = SSL_get_verify_result(ssl);
    if (sslState != X509_V_OK) {
      LOG_INFO("OpenSSL error: " 
	       << X509_verify_cert_error_string(sslState));
    }

    LOG_INFO("SSL handshake error: " << error.message());
    ConnectionManager_.stop(shared_from_this());
  }
}
Esempio n. 3
0
File: Server.C Progetto: bend/wt
void Server::handlePortSent(const boost::shared_ptr<asio::ip::tcp::socket>& socket,
			    const asio_error_code& err, const boost::shared_ptr<std::string>& /*buf*/)
{
  if (err) {
    LOG_ERROR_S(&wt_, "child process couldn't send listening port: " << err.message());
  }
  boost::system::error_code ignored_ec;
  if(socket.get()) {
	socket->shutdown(boost::asio::ip::tcp::socket::shutdown_both, ignored_ec);
	socket->close();
  }

}
Esempio n. 4
0
void Connection::handleWriteResponse(const asio_error_code& e,
    std::size_t bytes_transferred)
{
  LOG_DEBUG(socket().native() << ": handleWriteResponse(): "
      << bytes_transferred << " ; " << e.message());

  cancelWriteTimer();

  if (!e)
    handleWriteResponse();
  else if (e != asio::error::operation_aborted)
    handleError(e);
}
Esempio n. 5
0
void Connection::handleReadRequest(const asio_error_code& e,
				   std::size_t bytes_transferred)
{
  LOG_DEBUG(socket().native() << ": handleReadRequest(): " << e.message());

  cancelReadTimer();

  if (!e) {
    remaining_ = buffer_.data();
    buffer_size_ = bytes_transferred;
    handleReadRequest0();
  } else if (e != asio::error::operation_aborted &&
	     e != asio::error::bad_descriptor) {
    handleError(e);
  }
}
Esempio n. 6
0
void Connection::handleWriteResponse(ReplyPtr reply,
				     const asio_error_code& e,
				     std::size_t bytes_transferred)
{
  LOG_DEBUG(socket().native() << ": handleWriteResponse(): "
	    << bytes_transferred << " ; " << e.message());

  cancelWriteTimer();

  haveResponse_ = false;
  waitingResponse_ = true;
  reply->writeDone(!e);
  waitingResponse_ = false;

  if (!e) {
    handleWriteResponse(reply);
  } else {
    if (e != asio::error::operation_aborted)
      handleError(e);
  }
}
Esempio n. 7
0
File: Server.C Progetto: bend/wt
void Server::handleConnected(const boost::shared_ptr<asio::ip::tcp::socket>& socket,
			     const asio_error_code& err)
{
  if (!err) {
    boost::shared_ptr<std::string> buf(new std::string(
      boost::lexical_cast<std::string>(tcp_acceptor_.local_endpoint().port())));
    socket->async_send(asio::buffer(*buf),
      boost::bind(&Server::handlePortSent, this, socket, err, buf));
  } else {
    LOG_ERROR_S(&wt_, "child process couldn't connect to parent to send listening port: " << err.message());
  }
}
Esempio n. 8
0
void Connection::handleError(const asio_error_code& e)
{
  LOG_DEBUG(socket().native() << ": error: " << e.message());

  close();
}