Skip to content

Commit f411d4d

Browse files
committed
Update TcpConnection.cpp
Formatting tweaked and updated a debug log message
1 parent 783d9f1 commit f411d4d

1 file changed

Lines changed: 26 additions & 26 deletions

File tree

Source/Asio/TcpConnection.cpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ namespace tcp
4444
// ****************************************************************************
4545
// 'class TcpConnection' definition
4646
// ****************************************************************************
47-
TcpConnection::TcpConnection(asio_compat::io_service_t& ioService,
47+
TcpConnection::TcpConnection(asio_compat::io_service_t& ioService,
4848
const std::shared_ptr<TcpConnections>& connections,
4949
const defs::check_bytes_left_to_read_t& checkBytesLeftToRead,
5050
const defs::message_received_handler_t& messageReceivedHandler,
51-
const TcpConnSettings& settings,
51+
const TcpConnSettings& settings,
5252
const defs::message_received_handler_ex_t& messageReceivedHandlerEx,
5353
const defs::check_bytes_left_to_read_ex_t& checkBytesLeftToReadEx)
5454
: m_closing{false}
@@ -60,14 +60,16 @@ TcpConnection::TcpConnection(asio_compat::io_service_t& ioSer
6060
, m_messageReceivedHandlerEx{messageReceivedHandlerEx}
6161
, m_settings{settings}
6262
, m_connectEvent(threads::eNotifyType::signalOneThread, threads::eResetCondition::manualReset,
63-
threads::eIntialCondition::notSignalled)
63+
threads::eIntialCondition::notSignalled)
6464
, m_socket{ioService}
6565
{
6666
InitialiseMsgPool();
6767

6868
#if defined(USE_SOCKET_DEBUG)
69-
DEBUG_MESSAGE_EX_DEBUG(
70-
"Reserving memory for receive and send buffers as: " << DEFAULT_RESERVED_SIZE << " bytes");
69+
DEBUG_MESSAGE_EX_DEBUG("Reserving memory for receive buffer as: "
70+
<< static_cast<int32_t>(DEFAULT_SMALL_RESERVED_SIZE)
71+
<< " bytes, and accumulated message buffer as: "
72+
<< static_cast<int32_t>(DEFAULT_LARGE_RESERVED_SIZE) << " bytes");
7173
#endif
7274

7375
m_messageBuffer.reserve(DEFAULT_LARGE_RESERVED_SIZE);
@@ -356,8 +358,8 @@ void TcpConnection::ReadComplete(const boost_sys::error_code& error, size_t byte
356358
{
357359
numBytes =
358360
m_checkBytesLeftToReadEx(m_messageBuffer,
359-
m_socket.remote_endpoint().address().to_string(),
360-
m_socket.remote_endpoint().port());
361+
m_socket.remote_endpoint().address().to_string(),
362+
m_socket.remote_endpoint().port());
361363
}
362364
else
363365
{
@@ -375,8 +377,8 @@ void TcpConnection::ReadComplete(const boost_sys::error_code& error, size_t byte
375377
if (m_messageReceivedHandlerEx)
376378
{
377379
m_messageReceivedHandlerEx(m_messageBuffer,
378-
m_socket.remote_endpoint().address().to_string(),
379-
m_socket.remote_endpoint().port());
380+
m_socket.remote_endpoint().address().to_string(),
381+
m_socket.remote_endpoint().port());
380382
}
381383
else
382384
{
@@ -454,12 +456,12 @@ bool TcpConnection::SendMessageAsync(defs::char_buf_cspan_t message)
454456
return false;
455457
}
456458

457-
PendingWrite w;
459+
PendingWrite w;
458460

459-
if (!AcquirePendingWrite(message, w))
460-
{
461-
return false;
462-
}
461+
if (!AcquirePendingWrite(message, w))
462+
{
463+
return false;
464+
}
463465

464466
try
465467
{
@@ -488,7 +490,7 @@ bool TcpConnection::SendMessageAsync(defs::char_buf_cspan_t message)
488490

489491
bool TcpConnection::SendMessageSync(defs::char_buf_cspan_t message)
490492
{
491-
if (IsClosing())
493+
if (IsClosing())
492494
{
493495
return false;
494496
}
@@ -587,10 +589,7 @@ void TcpConnection::DoAsyncWriteOnStrand(const PendingWrite& w)
587589
boost_asio::buffer(block.data(), w.len),
588590
asio_compat::wrap(
589591
m_strand,
590-
boost::bind(&TcpConnection::WriteCompleteOnStrand,
591-
shared_from_this(),
592-
_1,
593-
_2)));
592+
boost::bind(&TcpConnection::WriteCompleteOnStrand, shared_from_this(), _1, _2)));
594593
}
595594
else
596595
{
@@ -603,8 +602,8 @@ void TcpConnection::DoAsyncWriteOnStrand(const PendingWrite& w)
603602
}
604603
}
605604

606-
void TcpConnection::WriteCompleteOnStrand(const boost_sys::error_code& error,
607-
CORELIB_ARG_MAYBE_UNUSED size_t bytesTransferred)
605+
void TcpConnection::WriteCompleteOnStrand(const boost_sys::error_code& error,
606+
CORELIB_ARG_MAYBE_UNUSED size_t bytesTransferred)
608607
{
609608
CORELIB_UNUSED_ARG(bytesTransferred)
610609

@@ -755,13 +754,14 @@ size_t TcpConnection::CurrentConnectionId() const NO_EXCEPT_
755754

756755
bool TcpConnection::AcquirePendingWrite(defs::char_buf_cspan_t message, PendingWrite& w)
757756
{
758-
const size_t maxAllowed = m_settings.maxAllowedUnsentAsyncMessages;
757+
const size_t maxAllowed = m_settings.maxAllowedUnsentAsyncMessages;
759758

760759
if (0 == maxAllowed)
761760
{
762761
#if defined(USE_SOCKET_DEBUG)
763-
DEBUG_MESSAGE_EX_DEBUG("Cannot send async message, max allowed unsent async messages is 0, for: "
764-
<< m_endPoint.first << ":" << m_endPoint.second);
762+
DEBUG_MESSAGE_EX_DEBUG(
763+
"Cannot send async message, max allowed unsent async messages is 0, for: "
764+
<< m_endPoint.first << ":" << m_endPoint.second);
765765
#endif
766766
return false;
767767
}
@@ -790,7 +790,7 @@ bool TcpConnection::AcquirePendingWrite(defs::char_buf_cspan_t message, PendingW
790790
{
791791
size_t idx = 0;
792792

793-
if (TryAcquirePoolIndex(idx))
793+
if (TryAcquirePoolIndex(idx))
794794
{
795795
// We exclusively own this pool slot now; safe to write off-strand.
796796
auto& block = m_msgPool[idx];
@@ -834,7 +834,7 @@ bool TcpConnection::AcquirePendingWrite(defs::char_buf_cspan_t message, PendingW
834834
}
835835
}
836836

837-
return true;
837+
return true;
838838
}
839839

840840
} // namespace tcp

0 commit comments

Comments
 (0)