Skip to content

Commit

Permalink
ExchangeContext remove unused flags
Browse files Browse the repository at this point in the history
  • Loading branch information
kghost committed Apr 26, 2022
1 parent 3a7f03a commit bc31d2e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 57 deletions.
1 change: 0 additions & 1 deletion src/messaging/ExchangeContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ ExchangeContext::ExchangeContext(ExchangeManager * em, uint16_t ExchangeId, cons
mFlags.Set(Flags::kFlagInitiator, Initiator);
mDelegate = delegate;

SetDropAckDebug(false);
SetAckPending(false);

// Do not request Ack for multicast
Expand Down
2 changes: 1 addition & 1 deletion src/messaging/ExchangeMessageDispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ CHIP_ERROR ExchangeMessageDispatch::SendMessage(SessionManager * sessionManager,
payloadHeader.SetExchangeID(exchangeId).SetMessageType(protocol, type).SetInitiator(isInitiator);

// If there is a pending acknowledgment piggyback it on this message.
if (reliableMessageContext->HasPiggybackAckPending())
if (reliableMessageContext->HasAckCounter())
{
payloadHeader.SetAckMessageCounter(reliableMessageContext->TakePendingPeerAckMessageCounter());

Expand Down
6 changes: 1 addition & 5 deletions src/messaging/ReliableMessageContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ void ReliableMessageContext::HandleRcvdAck(uint32_t ackMessageCounter)
CHIP_ERROR ReliableMessageContext::HandleNeedsAck(uint32_t messageCounter, BitFlags<MessageFlagValues> messageFlags)

{
// Skip processing ack if drop ack debug is enabled.
if (ShouldDropAckDebug())
return CHIP_NO_ERROR;

CHIP_ERROR err = HandleNeedsAckInner(messageCounter, messageFlags);

// Schedule next physical wakeup on function exit
Expand All @@ -129,7 +125,7 @@ CHIP_ERROR ReliableMessageContext::HandleNeedsAckInner(uint32_t messageCounter,

bool wasAckPending = IsAckPending() && mPendingPeerAckMessageCounter != messageCounter;

bool messageCounterWasValid = HasPiggybackAckPending();
bool messageCounterWasValid = HasAckCounter();

// Temporary store currently pending ack message counter (even if there is none).
uint32_t tempAckMessageCounter = mPendingPeerAckMessageCounter;
Expand Down
62 changes: 13 additions & 49 deletions src/messaging/ReliableMessageContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ReliableMessageContext

/**
* Take the pending peer ack message counter from the context. This must
* only be called when HasPiggybackAckPending() is true. After this call,
* only be called when HasAckCounter() is true. After this call,
* IsAckPending() will be false; it's the caller's responsibility to send
* the ack.
*/
Expand All @@ -67,11 +67,10 @@ class ReliableMessageContext
}

/**
* Check whether we have an ack to piggyback on the message we are sending.
* If true, TakePendingPeerAckMessageCounter will return a valid value that
* should be included as an ack in the message.
* Check whether we have a valid message counter. The counter is valid once received a message with a request ack flag. It never
* flips to false.
*/
bool HasPiggybackAckPending() const;
bool HasAckCounter() const;

/**
* Send a SecureChannel::StandaloneAck message.
Expand Down Expand Up @@ -102,26 +101,6 @@ class ReliableMessageContext
*/
void SetAutoRequestAck(bool autoReqAck);

/**
* Determine whether the ChipExchangeManager should not send an
* acknowledgement.
*
* For internal, debug use only.
*/
bool ShouldDropAckDebug() const;

/**
* Set whether the ChipExchangeManager should not send acknowledgements
* for this context.
*
* For internal, debug use only.
*
* @param[in] inDropAckDebug A Boolean indicating whether (true) or not
* (false) the acknowledgements should be not
* sent for the exchange.
*/
void SetDropAckDebug(bool inDropAckDebug);

/**
* Determine whether there is already an acknowledgment pending to be sent to the peer on this exchange.
*
Expand Down Expand Up @@ -159,29 +138,24 @@ class ReliableMessageContext
/// When set, automatically request an acknowledgment whenever a message is sent via UDP.
kFlagAutoRequestAck = (1u << 2),

/// Internal and debug only: when set, the exchange layer does not send an acknowledgment.
kFlagDropAckDebug = (1u << 3),

/// When set, signifies there is a message which hasn't been acknowledged.
kFlagMessageNotAcked = (1u << 4),
kFlagMessageNotAcked = (1u << 3),

/// When set, signifies that there is an acknowledgment pending to be sent back.
kFlagAckPending = (1u << 5),
kFlagAckPending = (1u << 4),

/// When set, signifies that there has once been an acknowledgment
/// pending to be sent back. In that case,
/// mPendingPeerAckMessageCounter is a valid message counter value for
/// some message we have needed to acknowledge in the past.
kFlagAckMessageCounterIsValid = (1u << 6),
/// When set, signifies that the message counter is valid.
/// The counter is valid once received a message with a request ack flag. It never flips to false.
kFlagAckMessageCounterIsValid = (1u << 5),

/// When set, signifies that this exchange is waiting for a call to SendMessage.
kFlagWillSendMessage = (1u << 7),
kFlagWillSendMessage = (1u << 6),

/// When set, we have had Close() or Abort() called on us already.
kFlagClosed = (1u << 8),
kFlagClosed = (1u << 7),

/// When set, signifies that the exchange is requesting Sleepy End Device fast-polling mode.
kFlagFastPollingMode = (1u << 9),
kFlagFastPollingMode = (1u << 8),
};

BitFlags<Flags> mFlags; // Internal state flags
Expand Down Expand Up @@ -228,12 +202,7 @@ inline bool ReliableMessageContext::IsMessageNotAcked() const
return mFlags.Has(Flags::kFlagMessageNotAcked);
}

inline bool ReliableMessageContext::ShouldDropAckDebug() const
{
return mFlags.Has(Flags::kFlagDropAckDebug);
}

inline bool ReliableMessageContext::HasPiggybackAckPending() const
inline bool ReliableMessageContext::HasAckCounter() const
{
return mFlags.Has(Flags::kFlagAckMessageCounterIsValid);
}
Expand All @@ -253,11 +222,6 @@ inline void ReliableMessageContext::SetAckPending(bool inAckPending)
mFlags.Set(Flags::kFlagAckPending, inAckPending);
}

inline void ReliableMessageContext::SetDropAckDebug(bool inDropAckDebug)
{
mFlags.Set(Flags::kFlagDropAckDebug, inDropAckDebug);
}

inline void ReliableMessageContext::SetMessageNotAcked(bool messageNotAcked)
{
mFlags.Set(Flags::kFlagMessageNotAcked, messageNotAcked);
Expand Down
2 changes: 1 addition & 1 deletion src/messaging/tests/TestReliableMessageProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class MockAppDelegate : public UnsolicitedMessageHandler, public ExchangeDelegat
if (mDropAckResponse)
{
auto * rc = ec->GetReliableMessageContext();
if (rc->HasPiggybackAckPending())
if (rc->HasAckCounter())
{
(void) rc->TakePendingPeerAckMessageCounter();
}
Expand Down

0 comments on commit bc31d2e

Please sign in to comment.