Ejemplo n.º 1
0
	/// Handle a signal from above
	/// For now we handle only terminate
	void handleSignal()
	{
		LOG_TRACE << "Signal received for connection to " << identifier();
		m_connHandler->signalOccured( ConnectionHandler::TERMINATE );

		nextOperation();
	}
Ejemplo n.º 2
0
	/// Handle the completion of a timer operation.
	void handleTimeout( const boost::system::error_code& e )
	{
		if ( !e )	{
			m_connHandler->signalOccured( ConnectionHandler::TIMEOUT );
			LOG_DEBUG << "Timeout on connection to " << identifier();

			nextOperation();
		}
		else	{
			assert( e == boost::asio::error::operation_aborted );
		}
	}
Ejemplo n.º 3
0
	/// Translate network error to processor error
	void signalError( const boost::system::error_code& e )
	{
		ConnectionHandler::NetworkSignal	ns;
		std::string				name;

		int errorcode = e.value();

#if defined(_WIN32)
#ifdef WITH_SSL
		// Rewrite error code got for a missing SSL_shutdown to a connection reset
		// because on Windows SSL_shutdown may not be called:
		if (e.category() == boost::asio::error::get_ssl_category()
		&&  e.value() == ERR_PACK(ERR_LIB_SSL, 0, SSL_R_SHORT_READ))
		{
			LOG_DEBUG << "Connection terminated abruptly by client, got no SSL_shutdown(); "
					<< "error: " << e.value() << ", category: " << e.category().name()
					<< ", message: " << e.message();
			errorcode = boost::asio::error::connection_reset;
		}
#endif
#endif
		switch( errorcode )	{
			case boost::asio::error::eof :
				ns = ConnectionHandler::END_OF_FILE;
				name = "EOF";
				break;
	
			case boost::asio::error::operation_aborted :
				ns = ConnectionHandler::OPERATION_CANCELLED;
				name = "OPERATION CANCELLED";
				break;
	
			case boost::asio::error::broken_pipe :
				ns = ConnectionHandler::BROKEN_PIPE;
				name = "BROKEN PIPE";
				break;
	
			case boost::asio::error::connection_reset :
				ns = ConnectionHandler::CONNECTION_RESET;
				name = "CONNECTION RESET";
				break;
			default:	{
				std::string err = e.message();
#ifdef WITH_SSL
				if ( e.category() == boost::asio::error::get_ssl_category() )	{
					err = std::string( "(" )
							+ boost::lexical_cast< std::string >( ERR_GET_LIB( e.value() ) ) + ", "
							+ boost::lexical_cast< std::string >( ERR_GET_FUNC( e.value() ) )+ ", "
							+ boost::lexical_cast< std::string >( ERR_GET_REASON( e.value() ) ) + ")";
					//ERR_PACK /* crypto/err/err.h */
					char buf[ 128 ];
					::ERR_error_string_n( e.value(), buf, sizeof( buf ) );
					err += buf;
				}
#endif // WITH_SSL
				LOG_DEBUG << "Unknown error: " << e.value() << ", category: " << e.category().name()
					  << ", message: " << err;
				ns = ConnectionHandler::UNKNOWN_ERROR;
				name = "UNKNOWN ERROR";
				break;
			}
		}
		m_connHandler->signalOccured( ns );
		LOG_DATA << "Signalled " << name << " to processor for connection to " << identifier();
	}