requester: Check duplicate key when call registerRequest
Add checking the existing of key {eid, instanceId, type, command}
when call registerRequest.
Tested:
1. Stress polling PLDM sensors.
2. Call pldmtool command to get sensor quickly.
3. Check message "The eid:InstanceID <eid>:<InstanceID> is using."
Change-Id: Ib547eb56e738a7aebfe87ce4967ebf1694e5b3ee
Signed-off-by: Thu Nguyen <thu@os.amperecomputing.com>
diff --git a/requester/handler.hpp b/requester/handler.hpp
index 9fa5c31..727adf9 100644
--- a/requester/handler.hpp
+++ b/requester/handler.hpp
@@ -165,6 +165,13 @@
}
};
+ if (handlers.contains(key))
+ {
+ error("The eid:InstanceID {EID}:{IID} is using.", "EID",
+ (unsigned)eid, "IID", (unsigned)instanceId);
+ return PLDM_ERROR;
+ }
+
auto request = std::make_unique<RequestInterface>(
fd, eid, event, std::move(requestMsg), numRetries, responseTimeOut,
currentSendbuffSize, verbose);