isc_throw(Unexpected, "internal error: unable to shutdown the socket");
}
+void
+HttpConnection::markWatchSocketReady() {
+ if (!watch_socket_) {
+ /// Should not happen...
+ return;
+ }
+ try {
+ watch_socket_->markReady();
+ } catch (const std::exception& ex) {
+ LOG_ERROR(http_logger, HTTP_CONNECTION_WATCH_SOCKET_MARK_READY_ERROR)
+ .arg(ex.what());
+ }
+}
+
+void
+HttpConnection::clearWatchSocket() {
+ if (!watch_socket_) {
+ /// Should not happen...
+ return;
+ }
+ try {
+ watch_socket_->clearReady();
+ } catch (const std::exception& ex) {
+ LOG_ERROR(http_logger, HTTP_CONNECTION_WATCH_SOCKET_CLEAR_ERROR)
+ .arg(ex.what());
+ }
+}
+
void
HttpConnection::closeWatchSocket() {
if (!watch_socket_) {
// Close watch socket and log errors if occur.
std::string watch_error;
if (!watch_socket_->closeSocket(watch_error)) {
- /// log
+ LOG_ERROR(http_logger, HTTP_CONNECTION_WATCH_SOCKET_CLOSE_ERROR)
+ .arg(watch_error);
}
}
try {
tls_socket_->handshake(cb);
if (use_external_) {
- // Asynchronous handshake has been scheduled and we need to
- // indicate this to break the synchronous select(). The handler
- // should clear this status when invoked.
- watch_socket_->markReady();
+ markWatchSocketReady();
}
} catch (const std::exception& ex) {
isc_throw(HttpConnectionError, "unable to perform TLS handshake: "
transaction->getOutputBufSize(),
cb);
if (use_external_) {
- // Asynchronous send has been scheduled and we
- // need to indicate this to break the synchronous
- // select(). The handler should clear this status
- // when invoked.
- watch_socket_->markReady();
+ markWatchSocketReady();
}
return;
}
transaction->getOutputBufSize(),
cb);
if (use_external_) {
- // Asynchronous send has been scheduled and we
- // need to indicate this to break the synchronous
- // select(). The handler should clear this status
- // when invoked.
- watch_socket_->markReady();
+ markWatchSocketReady();
}
return;
}
void
HttpConnection::handshakeCallback(const boost::system::error_code& ec) {
if (use_external_) {
- // Clear the watch socket so as the future send operation can
- // mark it again to interrupt the synchronous select() call.
- try {
- watch_socket_->clearReady();
- } catch (const std::exception& ex) {
- // log.
- }
+ clearWatchSocket();
}
if (ec) {
LOG_INFO(http_logger, HTTP_CONNECTION_HANDSHAKE_FAILED)
HttpConnection::socketWriteCallback(HttpConnection::TransactionPtr transaction,
boost::system::error_code ec, size_t length) {
if (use_external_) {
- // Clear the watch socket so as the future send operation can
- // mark it again to interrupt the synchronous select() call.
- try {
- watch_socket_->clearReady();
- } catch (const std::exception& ex) {
- // log.
- }
+ clearWatchSocket();
}
if (ec) {
// IO service has been stopped and the connection is probably
/// @brief Returns remote address in textual form
std::string getRemoteEndpointAddressAsText() const;
+ /// @brief Mark the watch socket as ready.
+ ///
+ /// Asynchronous handshake or send has been scheduled and we need to
+ /// indicate this to break the synchronous select(). The handler
+ /// should clear this status when invoked.
+ void markWatchSocketReady();
+
+ /// @brief Clear the watch socket's ready marker.
+ ///
+ /// Clear the watch socket so as the future send operation can
+ /// mark it again to interrupt the synchronous select() call.
+ void clearWatchSocket();
+
/// @brief Close the watch socket.
void closeWatchSocket();
extern const isc::log::MessageID HTTP_CONNECTION_SHUTDOWN_FAILED = "HTTP_CONNECTION_SHUTDOWN_FAILED";
extern const isc::log::MessageID HTTP_CONNECTION_STOP = "HTTP_CONNECTION_STOP";
extern const isc::log::MessageID HTTP_CONNECTION_STOP_FAILED = "HTTP_CONNECTION_STOP_FAILED";
+extern const isc::log::MessageID HTTP_CONNECTION_WATCH_SOCKET_CLEAR_ERROR = "HTTP_CONNECTION_WATCH_SOCKET_CLEAR_ERROR";
+extern const isc::log::MessageID HTTP_CONNECTION_WATCH_SOCKET_CLOSE_ERROR = "HTTP_CONNECTION_WATCH_SOCKET_CLOSE_ERROR";
+extern const isc::log::MessageID HTTP_CONNECTION_WATCH_SOCKET_MARK_READY_ERROR = "HTTP_CONNECTION_WATCH_SOCKET_MARK_READY_ERROR";
extern const isc::log::MessageID HTTP_DATA_RECEIVED = "HTTP_DATA_RECEIVED";
extern const isc::log::MessageID HTTP_IDLE_CONNECTION_TIMEOUT_OCCURRED = "HTTP_IDLE_CONNECTION_TIMEOUT_OCCURRED";
extern const isc::log::MessageID HTTP_PREMATURE_CONNECTION_TIMEOUT_OCCURRED = "HTTP_PREMATURE_CONNECTION_TIMEOUT_OCCURRED";
"HTTP_CONNECTION_SHUTDOWN_FAILED", "shutting down HTTP connection failed",
"HTTP_CONNECTION_STOP", "stopping HTTP connection from %1",
"HTTP_CONNECTION_STOP_FAILED", "stopping HTTP connection failed",
+ "HTTP_CONNECTION_WATCH_SOCKET_CLEAR_ERROR", "clearing connection watch socket failed: %1",
+ "HTTP_CONNECTION_WATCH_SOCKET_CLOSE_ERROR", "closing connection watch socket failed: %1",
+ "HTTP_CONNECTION_WATCH_SOCKET_MARK_READY_ERROR", "marking ready connection watch socket failed: %1",
"HTTP_DATA_RECEIVED", "received %1 bytes from %2",
"HTTP_IDLE_CONNECTION_TIMEOUT_OCCURRED", "closing persistent connection with %1 as a result of a timeout",
"HTTP_PREMATURE_CONNECTION_TIMEOUT_OCCURRED", "premature connection timeout occurred: in transaction ? %1, transid: %2, current_transid: %3",
extern const isc::log::MessageID HTTP_CONNECTION_SHUTDOWN_FAILED;
extern const isc::log::MessageID HTTP_CONNECTION_STOP;
extern const isc::log::MessageID HTTP_CONNECTION_STOP_FAILED;
+extern const isc::log::MessageID HTTP_CONNECTION_WATCH_SOCKET_CLEAR_ERROR;
+extern const isc::log::MessageID HTTP_CONNECTION_WATCH_SOCKET_CLOSE_ERROR;
+extern const isc::log::MessageID HTTP_CONNECTION_WATCH_SOCKET_MARK_READY_ERROR;
extern const isc::log::MessageID HTTP_DATA_RECEIVED;
extern const isc::log::MessageID HTTP_IDLE_CONNECTION_TIMEOUT_OCCURRED;
extern const isc::log::MessageID HTTP_PREMATURE_CONNECTION_TIMEOUT_OCCURRED;
This error message is issued when an error occurred during closing a
HTTP connection with a client.
+% HTTP_CONNECTION_WATCH_SOCKET_CLEAR_ERROR clearing connection watch socket failed: %1
+This error message is issued when an error occurred during clearing the
+watch socket associated with a HTTP connection with a client. The error
+is displayed.
+
+% HTTP_CONNECTION_WATCH_SOCKET_CLOSE_ERROR closing connection watch socket failed: %1
+This error message is issued when an error occurred during closing the
+watch socket associated with a HTTP connection with a client. The error
+is displayed.
+
+% HTTP_CONNECTION_WATCH_SOCKET_MARK_READY_ERROR marking ready connection watch socket failed: %1
+This error message is issued when an error occurred during marking as ready
+the watch socket associated with a HTTP connection with a client. The error
+is displayed.
+
% HTTP_DATA_RECEIVED received %1 bytes from %2
Logged at debug log level 55.
This debug message is issued when the server receives a chunk of data from