@@ -166,6 +166,34 @@ HttpConnection::shutdown() {
166
166
isc_throw (Unexpected, " internal error: unable to shutdown the socket" );
167
167
}
168
168
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
+
169
197
void
170
198
HttpConnection::closeWatchSocket () {
171
199
if (!watch_socket_) {
@@ -176,7 +204,8 @@ HttpConnection::closeWatchSocket() {
176
204
// Close watch socket and log errors if occur.
177
205
std::string watch_error;
178
206
if (!watch_socket_->closeSocket (watch_error)) {
179
- // / log
207
+ LOG_ERROR (http_logger, HTTP_CONNECTION_WATCH_SOCKET_CLOSE_ERROR)
208
+ .arg (watch_error);
180
209
}
181
210
}
182
211
@@ -283,10 +312,7 @@ HttpConnection::doHandshake() {
283
312
try {
284
313
tls_socket_->handshake (cb);
285
314
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 ();
290
316
}
291
317
} catch (const std::exception & ex) {
292
318
isc_throw (HttpConnectionError, " unable to perform TLS handshake: "
@@ -348,11 +374,7 @@ HttpConnection::doWrite(HttpConnection::TransactionPtr transaction) {
348
374
transaction->getOutputBufSize (),
349
375
cb);
350
376
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 ();
356
378
}
357
379
return ;
358
380
}
@@ -361,11 +383,7 @@ HttpConnection::doWrite(HttpConnection::TransactionPtr transaction) {
361
383
transaction->getOutputBufSize (),
362
384
cb);
363
385
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 ();
369
387
}
370
388
return ;
371
389
}
@@ -432,13 +450,7 @@ HttpConnection::acceptorCallback(const boost::system::error_code& ec) {
432
450
void
433
451
HttpConnection::handshakeCallback (const boost::system::error_code& ec) {
434
452
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 ();
442
454
}
443
455
if (ec) {
444
456
LOG_INFO (http_logger, HTTP_CONNECTION_HANDSHAKE_FAILED)
@@ -552,13 +564,7 @@ void
552
564
HttpConnection::socketWriteCallback (HttpConnection::TransactionPtr transaction,
553
565
boost::system::error_code ec, size_t length) {
554
566
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 ();
562
568
}
563
569
if (ec) {
564
570
// IO service has been stopped and the connection is probably
0 commit comments