Skip to content

Commit

Permalink
Heap-ify ReadHandler pool on the Server (project-chip#13066)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjerryjohns authored Jan 26, 2022
1 parent c0e4d7d commit 12db26d
Show file tree
Hide file tree
Showing 28 changed files with 833 additions and 401 deletions.
15 changes: 15 additions & 0 deletions config/standalone/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,21 @@
#define CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT 4
#endif

//
// Default of 8 ECs is not sufficient for some of the unit tests
// that try to validate multiple simultaneous interactions.
//
#define CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS 16

//
// Set this to a value greater than the value for CHIP_IM_MAX_NUM_READ_HANDLER
// to ensure some of the tests for validating resource exhaustion and heap allocation
// pass correctly.
//
// TODO: Once we fix ReadClients to be heap allocated, we no longer need this override.
//
#define CHIP_IM_MAX_NUM_READ_CLIENT 6

#define CONFIG_IM_BUILD_FOR_UNIT_TEST 1

#endif /* CHIPPROJECTCONFIG_H */
1 change: 1 addition & 0 deletions src/app/AttributeCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ class AttributeCache : protected ReadClient::Callback
void OnAttributeData(const ReadClient * apReadClient, const ConcreteDataAttributePath & aPath, TLV::TLVReader * apData,
const StatusIB & aStatus) override;
void OnError(const ReadClient * apReadClient, CHIP_ERROR aError) override { return mCallback.OnError(apReadClient, aError); }

void OnEventData(const ReadClient * apReadClient, const EventHeader & aEventHeader, TLV::TLVReader * apData,
const StatusIB * apStatus) override
{
Expand Down
17 changes: 9 additions & 8 deletions src/app/CommandHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,6 @@ class CommandHandler
*/
bool IsTimedInvoke() const { return mTimedRequest; }

/*
* This forcibly closes the exchange context if a valid one is pointed to. Such a situation does
* not arise during normal message processing flows that all normally call Close() above. This can only
* arise due to application-initiated destruction of the object when this object is handling receiving/sending
* message payloads.
*/
void Abort();

/**
* Gets the inner exchange context object, without ownership.
*
Expand All @@ -217,6 +209,15 @@ class CommandHandler

void MoveToState(const State aTargetState);
const char * GetStateStr() const;

/*
* This forcibly closes the exchange context if a valid one is pointed to. Such a situation does
* not arise during normal message processing flows that all normally call Close() above. This can only
* arise due to application-initiated destruction of the object when this object is handling receiving/sending
* message payloads.
*/
void Abort();

/**
* IncrementHoldOff will increase the inner refcount of the CommandHandler.
*
Expand Down
4 changes: 1 addition & 3 deletions src/app/DeviceControllerInteractionModelDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ namespace Controller {
*
* TODO:(#8967) Implementation of CommandSender::Callback should be removed after switching to ClusterObjects.
*/
class DeviceControllerInteractionModelDelegate : public chip::app::CommandSender::Callback,
public chip::app::WriteClient::Callback,
public chip::app::InteractionModelDelegate
class DeviceControllerInteractionModelDelegate : public chip::app::CommandSender::Callback, public chip::app::WriteClient::Callback
{
public:
DeviceControllerInteractionModelDelegate() {}
Expand Down
13 changes: 3 additions & 10 deletions src/app/InteractionModelDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,13 @@ class ReadHandler;
/**
* @brief
* This class defines the API for a delegate that an SDK consumer can use to interface with the interaction model.
*
* TODO: This delegate is now deprecated given we've shifted to narrower delegates scoped to each interaction type. This will
* eventually be deleted.
*/
class InteractionModelDelegate
{
public:
/**
* Notification that Subscription has been established successfully and application can do further work in handler.
*/
virtual CHIP_ERROR SubscriptionEstablished(const ReadHandler * apReadHandler) { return CHIP_ERROR_NOT_IMPLEMENTED; }

/**
* Notification that Subscription has been terminated in handler side.
*/
virtual CHIP_ERROR SubscriptionTerminated(const ReadHandler * apReadHandler) { return CHIP_ERROR_NOT_IMPLEMENTED; }

virtual ~InteractionModelDelegate() = default;
};

Expand Down
Loading

0 comments on commit 12db26d

Please sign in to comment.