Skip to content

Commit 4a600e7

Browse files
committed
[#3478] Checkpoint: added logs
1 parent 9e5db5d commit 4a600e7

File tree

5 files changed

+72
-29
lines changed

5 files changed

+72
-29
lines changed

src/lib/http/connection.cc

+35-29
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,34 @@ HttpConnection::shutdown() {
166166
isc_throw(Unexpected, "internal error: unable to shutdown the socket");
167167
}
168168

169+
void
170+
HttpConnection::markWatchSocketReady() {
171+
if (!watch_socket_) {
172+
/// Should not happen...
173+
return;
174+
}
175+
try {
176+
watch_socket_->markReady();
177+
} catch (const std::exception& ex) {
178+
LOG_ERROR(http_logger, HTTP_CONNECTION_WATCH_SOCKET_MARK_READY_ERROR)
179+
.arg(ex.what());
180+
}
181+
}
182+
183+
void
184+
HttpConnection::clearWatchSocket() {
185+
if (!watch_socket_) {
186+
/// Should not happen...
187+
return;
188+
}
189+
try {
190+
watch_socket_->clearReady();
191+
} catch (const std::exception& ex) {
192+
LOG_ERROR(http_logger, HTTP_CONNECTION_WATCH_SOCKET_CLEAR_ERROR)
193+
.arg(ex.what());
194+
}
195+
}
196+
169197
void
170198
HttpConnection::closeWatchSocket() {
171199
if (!watch_socket_) {
@@ -176,7 +204,8 @@ HttpConnection::closeWatchSocket() {
176204
// Close watch socket and log errors if occur.
177205
std::string watch_error;
178206
if (!watch_socket_->closeSocket(watch_error)) {
179-
/// log
207+
LOG_ERROR(http_logger, HTTP_CONNECTION_WATCH_SOCKET_CLOSE_ERROR)
208+
.arg(watch_error);
180209
}
181210
}
182211

@@ -283,10 +312,7 @@ HttpConnection::doHandshake() {
283312
try {
284313
tls_socket_->handshake(cb);
285314
if (use_external_) {
286-
// Asynchronous handshake has been scheduled and we need to
287-
// indicate this to break the synchronous select(). The handler
288-
// should clear this status when invoked.
289-
watch_socket_->markReady();
315+
markWatchSocketReady();
290316
}
291317
} catch (const std::exception& ex) {
292318
isc_throw(HttpConnectionError, "unable to perform TLS handshake: "
@@ -348,11 +374,7 @@ HttpConnection::doWrite(HttpConnection::TransactionPtr transaction) {
348374
transaction->getOutputBufSize(),
349375
cb);
350376
if (use_external_) {
351-
// Asynchronous send has been scheduled and we
352-
// need to indicate this to break the synchronous
353-
// select(). The handler should clear this status
354-
// when invoked.
355-
watch_socket_->markReady();
377+
markWatchSocketReady();
356378
}
357379
return;
358380
}
@@ -361,11 +383,7 @@ HttpConnection::doWrite(HttpConnection::TransactionPtr transaction) {
361383
transaction->getOutputBufSize(),
362384
cb);
363385
if (use_external_) {
364-
// Asynchronous send has been scheduled and we
365-
// need to indicate this to break the synchronous
366-
// select(). The handler should clear this status
367-
// when invoked.
368-
watch_socket_->markReady();
386+
markWatchSocketReady();
369387
}
370388
return;
371389
}
@@ -432,13 +450,7 @@ HttpConnection::acceptorCallback(const boost::system::error_code& ec) {
432450
void
433451
HttpConnection::handshakeCallback(const boost::system::error_code& ec) {
434452
if (use_external_) {
435-
// Clear the watch socket so as the future send operation can
436-
// mark it again to interrupt the synchronous select() call.
437-
try {
438-
watch_socket_->clearReady();
439-
} catch (const std::exception& ex) {
440-
// log.
441-
}
453+
clearWatchSocket();
442454
}
443455
if (ec) {
444456
LOG_INFO(http_logger, HTTP_CONNECTION_HANDSHAKE_FAILED)
@@ -552,13 +564,7 @@ void
552564
HttpConnection::socketWriteCallback(HttpConnection::TransactionPtr transaction,
553565
boost::system::error_code ec, size_t length) {
554566
if (use_external_) {
555-
// Clear the watch socket so as the future send operation can
556-
// mark it again to interrupt the synchronous select() call.
557-
try {
558-
watch_socket_->clearReady();
559-
} catch (const std::exception& ex) {
560-
// log.
561-
}
567+
clearWatchSocket();
562568
}
563569
if (ec) {
564570
// IO service has been stopped and the connection is probably

src/lib/http/connection.h

+13
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,19 @@ class HttpConnection : public boost::enable_shared_from_this<HttpConnection> {
402402
/// @brief Returns remote address in textual form
403403
std::string getRemoteEndpointAddressAsText() const;
404404

405+
/// @brief Mark the watch socket as ready.
406+
///
407+
/// Asynchronous handshake or send has been scheduled and we need to
408+
/// indicate this to break the synchronous select(). The handler
409+
/// should clear this status when invoked.
410+
void markWatchSocketReady();
411+
412+
/// @brief Clear the watch socket's ready marker.
413+
///
414+
/// Clear the watch socket so as the future send operation can
415+
/// mark it again to interrupt the synchronous select() call.
416+
void clearWatchSocket();
417+
405418
/// @brief Close the watch socket.
406419
void closeWatchSocket();
407420

src/lib/http/http_messages.cc

+6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ extern const isc::log::MessageID HTTP_CONNECTION_SHUTDOWN = "HTTP_CONNECTION_SHU
2626
extern const isc::log::MessageID HTTP_CONNECTION_SHUTDOWN_FAILED = "HTTP_CONNECTION_SHUTDOWN_FAILED";
2727
extern const isc::log::MessageID HTTP_CONNECTION_STOP = "HTTP_CONNECTION_STOP";
2828
extern const isc::log::MessageID HTTP_CONNECTION_STOP_FAILED = "HTTP_CONNECTION_STOP_FAILED";
29+
extern const isc::log::MessageID HTTP_CONNECTION_WATCH_SOCKET_CLEAR_ERROR = "HTTP_CONNECTION_WATCH_SOCKET_CLEAR_ERROR";
30+
extern const isc::log::MessageID HTTP_CONNECTION_WATCH_SOCKET_CLOSE_ERROR = "HTTP_CONNECTION_WATCH_SOCKET_CLOSE_ERROR";
31+
extern const isc::log::MessageID HTTP_CONNECTION_WATCH_SOCKET_MARK_READY_ERROR = "HTTP_CONNECTION_WATCH_SOCKET_MARK_READY_ERROR";
2932
extern const isc::log::MessageID HTTP_DATA_RECEIVED = "HTTP_DATA_RECEIVED";
3033
extern const isc::log::MessageID HTTP_IDLE_CONNECTION_TIMEOUT_OCCURRED = "HTTP_IDLE_CONNECTION_TIMEOUT_OCCURRED";
3134
extern const isc::log::MessageID HTTP_PREMATURE_CONNECTION_TIMEOUT_OCCURRED = "HTTP_PREMATURE_CONNECTION_TIMEOUT_OCCURRED";
@@ -60,6 +63,9 @@ const char* values[] = {
6063
"HTTP_CONNECTION_SHUTDOWN_FAILED", "shutting down HTTP connection failed",
6164
"HTTP_CONNECTION_STOP", "stopping HTTP connection from %1",
6265
"HTTP_CONNECTION_STOP_FAILED", "stopping HTTP connection failed",
66+
"HTTP_CONNECTION_WATCH_SOCKET_CLEAR_ERROR", "clearing connection watch socket failed: %1",
67+
"HTTP_CONNECTION_WATCH_SOCKET_CLOSE_ERROR", "closing connection watch socket failed: %1",
68+
"HTTP_CONNECTION_WATCH_SOCKET_MARK_READY_ERROR", "marking ready connection watch socket failed: %1",
6369
"HTTP_DATA_RECEIVED", "received %1 bytes from %2",
6470
"HTTP_IDLE_CONNECTION_TIMEOUT_OCCURRED", "closing persistent connection with %1 as a result of a timeout",
6571
"HTTP_PREMATURE_CONNECTION_TIMEOUT_OCCURRED", "premature connection timeout occurred: in transaction ? %1, transid: %2, current_transid: %3",

src/lib/http/http_messages.h

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ extern const isc::log::MessageID HTTP_CONNECTION_SHUTDOWN;
2727
extern const isc::log::MessageID HTTP_CONNECTION_SHUTDOWN_FAILED;
2828
extern const isc::log::MessageID HTTP_CONNECTION_STOP;
2929
extern const isc::log::MessageID HTTP_CONNECTION_STOP_FAILED;
30+
extern const isc::log::MessageID HTTP_CONNECTION_WATCH_SOCKET_CLEAR_ERROR;
31+
extern const isc::log::MessageID HTTP_CONNECTION_WATCH_SOCKET_CLOSE_ERROR;
32+
extern const isc::log::MessageID HTTP_CONNECTION_WATCH_SOCKET_MARK_READY_ERROR;
3033
extern const isc::log::MessageID HTTP_DATA_RECEIVED;
3134
extern const isc::log::MessageID HTTP_IDLE_CONNECTION_TIMEOUT_OCCURRED;
3235
extern const isc::log::MessageID HTTP_PREMATURE_CONNECTION_TIMEOUT_OCCURRED;

src/lib/http/http_messages.mes

+15
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,21 @@ successful message exchange with a client.
128128
This error message is issued when an error occurred during closing a
129129
HTTP connection with a client.
130130

131+
% HTTP_CONNECTION_WATCH_SOCKET_CLEAR_ERROR clearing connection watch socket failed: %1
132+
This error message is issued when an error occurred during clearing the
133+
watch socket associated with a HTTP connection with a client. The error
134+
is displayed.
135+
136+
% HTTP_CONNECTION_WATCH_SOCKET_CLOSE_ERROR closing connection watch socket failed: %1
137+
This error message is issued when an error occurred during closing the
138+
watch socket associated with a HTTP connection with a client. The error
139+
is displayed.
140+
141+
% HTTP_CONNECTION_WATCH_SOCKET_MARK_READY_ERROR marking ready connection watch socket failed: %1
142+
This error message is issued when an error occurred during marking as ready
143+
the watch socket associated with a HTTP connection with a client. The error
144+
is displayed.
145+
131146
% HTTP_DATA_RECEIVED received %1 bytes from %2
132147
Logged at debug log level 55.
133148
This debug message is issued when the server receives a chunk of data from

0 commit comments

Comments
 (0)