-
Notifications
You must be signed in to change notification settings - Fork 387
Do not refresh object store before fetching object. #614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Thanks for your PR; the reason it is implemented the way it currently is is to cope with multiple independent processes concurrently manipulating the same token through the SoftHSM library. If you disable the check, then a process will fail to pick up any changes to the token made by an external process. I understand that for performance reasons this is inconvenient, but perhaps it would be better, if you want to be able to disable it, to make this a configurable feature? I'm wondering, though, if that should then be run-time configurable or compile-time (since you might not want two processes using SoftHSM with conflicting configurations). I'd like to ask @halderen for an opinion on this too. |
|
It is really needed that multiple concurrent processes access the same token at the same time for many use cases. I'd first like to know the performance impact of such a thing. SoftHSMv2 isn't really that fast anyway (for security reasons) so if the effect isn't good for me. Not having the lock (so this PR) means bringing back the old SoftHSMv1 functionality and the way SoftHSMv2 sometimes operate due to a bug. This took us with OpenDNSSEC 2 1/2 years to find, so I'd rather not burn application programmers with this. In any case, this should not be a compile time option, as this would mean package maintainers may select this, and then everyone may be stuck with this. It should be a run-time, per slot/token option (but that might not be possible) option that is not default on. |
|
I'm glad that you are willing to accept my proposal with the modification that the 'refresh disabling' should be optional and disabled by default. Could we add a key called objectstore.readrefresh to the softhsm2.conf . If this key has the value 'false' then no refreshing is done before fetching an object from the store, if something else or not define then the refresh is done (as before). I have just tested this with the file mode. Maybe nothing should be done about the DB mode (I removed a mutex lock)? I believe it should be possible in 'file mode' for several processes to use the same objects in a store with 'objectstore.readrefresh=false'. There will just be a problem if one of the processes use C_DestroyObject or C_SetAttribute; |
|
New version ready for review. |
BenchmarksI have compared result from a Debian VM running the p11speed test with different configurations. p11speed has used 24 threads each doing 1000 signings with 2048 RSA_PKCS.
I will remove my DB fix since it is not doing any difference. |
|
Please rebase on develop and mark as ready when ready. |
d2de4f5 to
46ae6eb
Compare
|
Now all tests but windows are OK. But I don't think these problem has anything to do with this. |
|
how stupid of me. I did just assume the the windows build was not ready yet. |
Before this commit the object store for a file token was always refreshed by reading the file of the token every time an object of the token was fetched. Now the HSM may be configured not to refresh when fetching an object. But the refresh will still be done after an application gets a handle for an object. The reason for this change is that the CPU time consumed by the reading may not be negligible for some HW. It is only the objects store on file that are affected by this feature. If DB is used refreshing will always be done since the is then no difference in CPU usage.
WalkthroughA new configuration-driven boolean flag, Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant SoftHSM
participant OSObject
User->>SoftHSM: Call operation (e.g., C_CopyObject)
SoftHSM->>OSObject: isValid(doRefresh)
OSObject-->>SoftHSM: Validity result (with/without refresh)
SoftHSM-->>User: Operation result
Estimated code review effort4 (~80 minutes) Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (5)
src/lib/common/softhsm2.conf.5.in (1)
105-129: Comprehensive documentation with clear trade-off explanation.The documentation thoroughly explains the new configuration option, including its performance benefits and the important caveat about stale object handles in multi-process environments. The warning about potential issues when objects are modified by other processes is particularly valuable.
Note: There's a minor inconsistency where the text states "Default is true" but the example shows
objectstore.readrefresh = false. Consider aligning the example with the documented default or clarifying this is showing the performance-optimized setting.src/lib/object_store/test/ObjectFileTestsRefresh.cpp (1)
28-28: Fix the filename in the comment.- ObjectObjectFileTests.cpp + ObjectFileTestsRefresh.cppsrc/lib/object_store/test/ObjectFileTestsNoRefresh.cpp (2)
28-28: Fix typo in file comment.The comment should read "ObjectFileTestsNoRefresh.cpp" instead of "ObjectObjectFileTests.cpp".
-/***************************************************************************** - ObjectObjectFileTests.cpp - - Contains test cases to test the object file implementation - *****************************************************************************/ +/***************************************************************************** + ObjectFileTestsNoRefresh.cpp + + Contains test cases to test the object file implementation + *****************************************************************************/
39-55: Consider improving error handling consistency and command security.While the system() calls are acceptable for test code, there are some improvements to consider:
- The Windows version in
setUp()doesn't assert on success like the Unix version- Static analysis flags system() calls as potential security risks (CWE-78)
For consistency, consider adding error checking to the Windows path in
setUp():void ObjectFileTestsNoRefresh::setUp() { #ifndef _WIN32 CPPUNIT_ASSERT(!system("mkdir testdir")); #else - system("mkdir testdir 2> nul"); + CPPUNIT_ASSERT(!system("mkdir testdir 2> nul")); #endif }Note: The system() calls are flagged by static analysis but are acceptable here since they use hardcoded, safe commands in a test environment.
src/lib/object_store/test/ObjectFileTestsNoRefresh.h (1)
37-37: Consider removing unused include.The include of
"test/SessionObjectTests.h"appears unnecessary unless this class uses functionality fromSessionObjectTests. Consider removing it if it's not needed.#include "ObjectFileTests.h" -#include "test/SessionObjectTests.h" #include <cppunit/extensions/HelperMacros.h>
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (22)
src/lib/SoftHSM.cpp(23 hunks)src/lib/SoftHSM.h(1 hunks)src/lib/common/Configuration.cpp(1 hunks)src/lib/common/softhsm2.conf.5.in(1 hunks)src/lib/common/softhsm2.conf.in(1 hunks)src/lib/object_store/DBObject.cpp(1 hunks)src/lib/object_store/DBObject.h(1 hunks)src/lib/object_store/DBToken.cpp(1 hunks)src/lib/object_store/OSObject.h(1 hunks)src/lib/object_store/OSToken.cpp(5 hunks)src/lib/object_store/ObjectFile.cpp(1 hunks)src/lib/object_store/ObjectFile.h(1 hunks)src/lib/object_store/SessionObject.cpp(1 hunks)src/lib/object_store/SessionObject.h(1 hunks)src/lib/object_store/SessionObjectStore.cpp(1 hunks)src/lib/object_store/test/Makefile.am(1 hunks)src/lib/object_store/test/ObjectFileTests.cpp(31 hunks)src/lib/object_store/test/ObjectFileTests.h(2 hunks)src/lib/object_store/test/ObjectFileTestsNoRefresh.cpp(1 hunks)src/lib/object_store/test/ObjectFileTestsNoRefresh.h(1 hunks)src/lib/object_store/test/ObjectFileTestsRefresh.cpp(1 hunks)src/lib/object_store/test/ObjectFileTestsRefresh.h(1 hunks)
🧬 Code Graph Analysis (10)
src/lib/object_store/DBObject.h (3)
src/lib/object_store/DBObject.cpp (2)
isValid(1367-1372)isValid(1367-1367)src/lib/object_store/SessionObject.cpp (2)
isValid(221-224)isValid(221-221)src/lib/object_store/ObjectFile.cpp (2)
isValid(266-273)isValid(266-266)
src/lib/object_store/DBObject.cpp (2)
src/lib/object_store/SessionObject.cpp (2)
isValid(221-224)isValid(221-221)src/lib/object_store/ObjectFile.cpp (2)
isValid(266-273)isValid(266-266)
src/lib/object_store/SessionObject.cpp (5)
src/lib/object_store/DBObject.cpp (2)
isValid(1367-1372)isValid(1367-1367)src/lib/object_store/DBToken.cpp (2)
isValid(746-749)isValid(746-746)src/lib/object_store/OSToken.cpp (2)
isValid(444-447)isValid(444-444)src/lib/object_store/ObjectFile.cpp (2)
isValid(266-273)isValid(266-266)src/lib/slot_mgr/Token.cpp (2)
isValid(75-81)isValid(75-75)
src/lib/object_store/ObjectFile.cpp (3)
src/lib/object_store/DBObject.cpp (2)
isValid(1367-1372)isValid(1367-1367)src/lib/object_store/SessionObject.cpp (2)
isValid(221-224)isValid(221-221)src/lib/object_store/Directory.cpp (4)
isValid(68-71)isValid(68-68)refresh(94-222)refresh(94-94)
src/lib/object_store/SessionObject.h (6)
src/lib/object_store/DBObject.cpp (2)
isValid(1367-1372)isValid(1367-1367)src/lib/object_store/DBToken.cpp (2)
isValid(746-749)isValid(746-746)src/lib/object_store/OSToken.cpp (2)
isValid(444-447)isValid(444-444)src/lib/object_store/SessionObject.cpp (2)
isValid(221-224)isValid(221-221)src/lib/object_store/ObjectFile.cpp (2)
isValid(266-273)isValid(266-266)src/lib/slot_mgr/Token.cpp (2)
isValid(75-81)isValid(75-75)
src/lib/object_store/test/ObjectFileTestsRefresh.cpp (1)
src/lib/object_store/test/ObjectFileTestsNoRefresh.cpp (4)
setUp(39-46)setUp(39-39)tearDown(48-55)tearDown(48-48)
src/lib/object_store/test/ObjectFileTests.h (1)
src/lib/object_store/test/ObjectFileTests.cpp (3)
ObjectFileTests(48-50)testBoolAttr(52-120)testBoolAttr(52-52)
src/lib/object_store/test/ObjectFileTestsNoRefresh.cpp (1)
src/lib/object_store/test/ObjectFileTestsRefresh.cpp (4)
setUp(39-46)setUp(39-39)tearDown(48-55)tearDown(48-48)
src/lib/object_store/OSObject.h (6)
src/lib/object_store/DBObject.cpp (2)
isValid(1367-1372)isValid(1367-1367)src/lib/object_store/DBToken.cpp (2)
isValid(746-749)isValid(746-746)src/lib/object_store/OSToken.cpp (2)
isValid(444-447)isValid(444-444)src/lib/object_store/SessionObject.cpp (2)
isValid(221-224)isValid(221-221)src/lib/object_store/ObjectFile.cpp (2)
isValid(266-273)isValid(266-266)src/lib/object_store/File.cpp (2)
isValid(147-150)isValid(147-147)
src/lib/object_store/test/ObjectFileTestsNoRefresh.h (3)
src/lib/object_store/test/ObjectFileTestsNoRefresh.cpp (5)
ObjectFileTestsNoRefresh(37-37)setUp(39-46)setUp(39-39)tearDown(48-55)tearDown(48-48)src/lib/object_store/test/ObjectFileTests.h (1)
ObjectFileTests(37-55)src/lib/object_store/test/ObjectFileTests.cpp (23)
ObjectFileTests(48-50)testBoolAttr(52-120)testBoolAttr(52-52)testULongAttr(122-190)testULongAttr(122-122)testByteStrAttr(192-259)testByteStrAttr(192-192)testMechTypeSetAttr(261-303)testMechTypeSetAttr(261-261)testAttrMapAttr(305-369)testAttrMapAttr(305-305)testMixedAttr(371-428)testMixedAttr(371-371)testDoubleAttr(430-548)testDoubleAttr(430-430)testRefresh(550-692)testRefresh(550-550)testCorruptFile(694-716)testCorruptFile(694-694)testTransactions(718-882)testTransactions(718-718)testDestroyObjectFails(884-898)testDestroyObjectFails(884-884)
🪛 ast-grep (0.38.6)
src/lib/object_store/test/ObjectFileTestsRefresh.cpp
[warning] 43-43: Don't call system. It's a high-level wrapper that allows for stacking multiple commands. Always prefer a more restrictive API such as calling execve from the exec family.
Context: system("mkdir testdir 2> nul");
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS
Command ('OS Command Injection').
[REFERENCES]
- https://owasp.org/Top10/A03_2021-Injection
(dont-call-system-cpp)
src/lib/object_store/test/ObjectFileTestsNoRefresh.cpp
[warning] 43-43: Don't call system. It's a high-level wrapper that allows for stacking multiple commands. Always prefer a more restrictive API such as calling execve from the exec family.
Context: system("mkdir testdir 2> nul");
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS
Command ('OS Command Injection').
[REFERENCES]
- https://owasp.org/Top10/A03_2021-Injection
(dont-call-system-cpp)
🧰 Additional context used
🧬 Code Graph Analysis (10)
src/lib/object_store/DBObject.h (3)
src/lib/object_store/DBObject.cpp (2)
isValid(1367-1372)isValid(1367-1367)src/lib/object_store/SessionObject.cpp (2)
isValid(221-224)isValid(221-221)src/lib/object_store/ObjectFile.cpp (2)
isValid(266-273)isValid(266-266)
src/lib/object_store/DBObject.cpp (2)
src/lib/object_store/SessionObject.cpp (2)
isValid(221-224)isValid(221-221)src/lib/object_store/ObjectFile.cpp (2)
isValid(266-273)isValid(266-266)
src/lib/object_store/SessionObject.cpp (5)
src/lib/object_store/DBObject.cpp (2)
isValid(1367-1372)isValid(1367-1367)src/lib/object_store/DBToken.cpp (2)
isValid(746-749)isValid(746-746)src/lib/object_store/OSToken.cpp (2)
isValid(444-447)isValid(444-444)src/lib/object_store/ObjectFile.cpp (2)
isValid(266-273)isValid(266-266)src/lib/slot_mgr/Token.cpp (2)
isValid(75-81)isValid(75-75)
src/lib/object_store/ObjectFile.cpp (3)
src/lib/object_store/DBObject.cpp (2)
isValid(1367-1372)isValid(1367-1367)src/lib/object_store/SessionObject.cpp (2)
isValid(221-224)isValid(221-221)src/lib/object_store/Directory.cpp (4)
isValid(68-71)isValid(68-68)refresh(94-222)refresh(94-94)
src/lib/object_store/SessionObject.h (6)
src/lib/object_store/DBObject.cpp (2)
isValid(1367-1372)isValid(1367-1367)src/lib/object_store/DBToken.cpp (2)
isValid(746-749)isValid(746-746)src/lib/object_store/OSToken.cpp (2)
isValid(444-447)isValid(444-444)src/lib/object_store/SessionObject.cpp (2)
isValid(221-224)isValid(221-221)src/lib/object_store/ObjectFile.cpp (2)
isValid(266-273)isValid(266-266)src/lib/slot_mgr/Token.cpp (2)
isValid(75-81)isValid(75-75)
src/lib/object_store/test/ObjectFileTestsRefresh.cpp (1)
src/lib/object_store/test/ObjectFileTestsNoRefresh.cpp (4)
setUp(39-46)setUp(39-39)tearDown(48-55)tearDown(48-48)
src/lib/object_store/test/ObjectFileTests.h (1)
src/lib/object_store/test/ObjectFileTests.cpp (3)
ObjectFileTests(48-50)testBoolAttr(52-120)testBoolAttr(52-52)
src/lib/object_store/test/ObjectFileTestsNoRefresh.cpp (1)
src/lib/object_store/test/ObjectFileTestsRefresh.cpp (4)
setUp(39-46)setUp(39-39)tearDown(48-55)tearDown(48-48)
src/lib/object_store/OSObject.h (6)
src/lib/object_store/DBObject.cpp (2)
isValid(1367-1372)isValid(1367-1367)src/lib/object_store/DBToken.cpp (2)
isValid(746-749)isValid(746-746)src/lib/object_store/OSToken.cpp (2)
isValid(444-447)isValid(444-444)src/lib/object_store/SessionObject.cpp (2)
isValid(221-224)isValid(221-221)src/lib/object_store/ObjectFile.cpp (2)
isValid(266-273)isValid(266-266)src/lib/object_store/File.cpp (2)
isValid(147-150)isValid(147-147)
src/lib/object_store/test/ObjectFileTestsNoRefresh.h (3)
src/lib/object_store/test/ObjectFileTestsNoRefresh.cpp (5)
ObjectFileTestsNoRefresh(37-37)setUp(39-46)setUp(39-39)tearDown(48-55)tearDown(48-48)src/lib/object_store/test/ObjectFileTests.h (1)
ObjectFileTests(37-55)src/lib/object_store/test/ObjectFileTests.cpp (23)
ObjectFileTests(48-50)testBoolAttr(52-120)testBoolAttr(52-52)testULongAttr(122-190)testULongAttr(122-122)testByteStrAttr(192-259)testByteStrAttr(192-192)testMechTypeSetAttr(261-303)testMechTypeSetAttr(261-261)testAttrMapAttr(305-369)testAttrMapAttr(305-305)testMixedAttr(371-428)testMixedAttr(371-371)testDoubleAttr(430-548)testDoubleAttr(430-430)testRefresh(550-692)testRefresh(550-550)testCorruptFile(694-716)testCorruptFile(694-694)testTransactions(718-882)testTransactions(718-718)testDestroyObjectFails(884-898)testDestroyObjectFails(884-884)
🪛 ast-grep (0.38.6)
src/lib/object_store/test/ObjectFileTestsRefresh.cpp
[warning] 43-43: Don't call system. It's a high-level wrapper that allows for stacking multiple commands. Always prefer a more restrictive API such as calling execve from the exec family.
Context: system("mkdir testdir 2> nul");
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS
Command ('OS Command Injection').
[REFERENCES]
- https://owasp.org/Top10/A03_2021-Injection
(dont-call-system-cpp)
src/lib/object_store/test/ObjectFileTestsNoRefresh.cpp
[warning] 43-43: Don't call system. It's a high-level wrapper that allows for stacking multiple commands. Always prefer a more restrictive API such as calling execve from the exec family.
Context: system("mkdir testdir 2> nul");
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS
Command ('OS Command Injection').
[REFERENCES]
- https://owasp.org/Top10/A03_2021-Injection
(dont-call-system-cpp)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: Windows (x64, botan)
- GitHub Check: Windows (x64, openssl)
- GitHub Check: Windows (x86, openssl)
- GitHub Check: macOS (openssl)
- GitHub Check: macOS (botan)
🔇 Additional comments (34)
src/lib/SoftHSM.h (1)
189-190: LGTM! Clean addition of configuration flag.The new
doRefreshboolean member is well-documented and appropriately placed in the private section. This will effectively control whether objects are refreshed from storage before validation based on the configuration setting.src/lib/common/softhsm2.conf.in (1)
19-20: LGTM! Good configuration option with safe default.The new
objectstore.readrefreshparameter is well-documented and usestrueas the default to maintain backward compatibility. This addresses the performance concerns raised in the PR while preserving existing multi-process safety by default.src/lib/object_store/DBObject.h (1)
99-99: LGTM! Interface consistency maintained.The
isValid()method signature update to accept thedoRefreshparameter maintains consistency across the object store hierarchy. For database objects, this parameter is appropriately ignored since they don't need refresh from storage (as seen in the implementation atsrc/lib/object_store/DBObject.cpplines 1366-1371).src/lib/object_store/SessionObject.h (1)
76-77: LGTM! Clean interface update with clear documentation.The addition of the
doRefreshparameter with default value maintains interface consistency across object store classes. The comment clearly explains why this parameter is not applicable to session objects (since they don't persist on disk), and the implementation correctly ignores it as expected.src/lib/common/Configuration.cpp (1)
54-54: LGTM! Proper configuration key registration.The new
objectstore.readrefreshconfiguration key is correctly registered with the appropriateCONFIG_TYPE_BOOLtype. This enables the configuration system to properly validate and handle the new refresh control parameter.src/lib/object_store/ObjectFile.h (1)
79-79: LGTM! Clean method signature update.The addition of the
doRefreshparameter to theisValid()method is consistent with the PR's goal of making refresh behavior configurable.src/lib/object_store/SessionObjectStore.cpp (1)
109-109: LGTM! Appropriate parameter value for session objects.Passing
falsefordoRefreshis correct since session objects are not persisted to disk and have nothing to refresh from storage.src/lib/object_store/test/Makefile.am (1)
20-21: LGTM! Proper test integration.The new test source files are correctly added to the build system, providing test coverage for both refresh and no-refresh scenarios.
src/lib/object_store/DBObject.cpp (1)
1367-1367: Verify Windows compatibility of__attribute__((unused)).Based on the past review comments on
SessionObject.cpp, there was a Windows build failure with the__attribute__((unused))syntax. Please ensure this has been addressed consistently across all files using this pattern.Consider using portable alternatives like:
bool DBObject::isValid(const bool /*doRefresh*/)or adding
(void)doRefresh;in the function body if the attribute approach causes build issues.src/lib/object_store/SessionObject.cpp (1)
220-221: Excellent approach for cross-platform compatibility.Using the commented parameter name
/*doRefresh*/instead of__attribute__((unused))is the correct portable solution for unused parameters. This approach avoids the Windows build issues mentioned in previous reviews while maintaining clear documentation of the parameter's purpose.src/lib/object_store/ObjectFile.cpp (1)
265-273: LGTM! Clean implementation of configurable refresh behavior.The method correctly implements the conditional refresh logic while maintaining backward compatibility. The updated comment accurately reflects that refreshing "may" occur as a side effect rather than always occurring.
src/lib/object_store/DBToken.cpp (1)
687-687: LGTM! Correct alignment with updated method signature.The change appropriately passes
trueto maintain the original behavior of refreshing before validation, which is suitable for newly created objects where we want to ensure proper validation.src/lib/object_store/OSObject.h (1)
67-68: LGTM! Well-designed interface update with backward compatibility.The addition of the
doRefreshparameter with a default value oftruemaintains backward compatibility while enabling the new configurable refresh behavior. The accompanying comment clearly explains the parameter's purpose.src/lib/object_store/test/ObjectFileTestsRefresh.cpp (1)
37-55: Test class structure is well-designed.The test class correctly inherits from
ObjectFileTestswith refresh enabled (true), and the setUp/tearDown methods follow the established pattern used in similar test files. The use ofsystem()calls, while flagged by static analysis, is consistent with the existing test infrastructure in this codebase.src/lib/object_store/OSToken.cpp (5)
182-183: Good approach to handle token metadata operations.Hardcoding refresh to
truefor token metadata operations is appropriate since these are infrequent but critical operations where data consistency is paramount.
227-228: Consistent implementation with appropriate refresh behavior.The forced refresh for user PIN operations maintains data integrity for this security-critical function.
248-249: Proper refresh handling for token label retrieval.The comment correctly explains that this operation is rare enough that the refresh overhead is acceptable for ensuring consistency.
269-270: Appropriate refresh behavior for token serial operations.Maintaining consistency for token serial retrieval by forcing refresh is the right choice given the infrequent nature of this operation.
290-291: Correct refresh handling for token flags.Token flags are critical for security state management, so forcing refresh ensures the most current state is always retrieved.
src/lib/object_store/test/ObjectFileTests.h (2)
37-40: Well-designed refactoring to support configurable test scenarios.Converting
ObjectFileTeststo a parameterized base class is an excellent approach for testing both refresh-enabled and refresh-disabled behaviors. The constructor parameter allows concrete test classes to specify their refresh behavior.
53-54: Good use of const member for immutable configuration.Making
doRefreshconst ensures the refresh behavior cannot be accidentally modified during test execution, providing clear and consistent test semantics.src/lib/object_store/test/ObjectFileTestsNoRefresh.cpp (1)
37-37: Constructor correctly configures refresh behavior.The constructor properly passes
falseto the base class, ensuring that all tests in this suite run without refresh enabled.src/lib/object_store/test/ObjectFileTestsRefresh.h (1)
41-62: Well-structured test class design.The class design effectively combines the parameterized
ObjectFileTestsbase class with CppUnit test infrastructure. The complete test suite registration ensures all object file functionality is tested with refresh enabled.src/lib/object_store/test/ObjectFileTestsNoRefresh.h (1)
41-62: Consistent and well-designed test class structure.The class design properly mirrors
ObjectFileTestsRefreshand correctly integrates with the CppUnit framework. All necessary test methods are registered in the suite.src/lib/object_store/test/ObjectFileTests.cpp (7)
48-50: LGTM! Clean constructor implementation.The constructor properly initializes the
doRefreshmember variable using the initialization list, which is the correct C++ pattern.
62-893: LGTM! Systematic addition of doRefresh parameter to isValid() calls.All
isValid()calls have been consistently updated to pass thedoRefreshparameter throughout the test file. This systematic change properly supports the new configurable refresh behavior while maintaining existing test functionality.
670-674: LGTM! Conditional test logic correctly validates refresh behavior.The conditional assertions properly test that when
doRefresh=false, the first object instance doesn't see changes made by the second instance, which is the expected behavior for the performance optimization.
687-691: LGTM! Proper validation of refresh behavior in multi-instance scenario.The conditional assertion correctly verifies that when
doRefresh=false, changes made by one object instance are not reflected in another instance, which aligns with the performance optimization goals.
814-824: LGTM! Transaction test logic properly handles both refresh modes.The conditional assertions correctly test that after a transaction commit, changes are only visible to other instances when
doRefresh=true. This validates both the traditional behavior and the new performance optimization mode.
853-856: LGTM! Consistent conditional testing pattern.The assertions maintain the same pattern of validating that when
doRefresh=false, object instances maintain their cached state without reflecting external changes.
878-881: LGTM! Final validation of refresh behavior after transaction abort.The conditional assertions properly test that even after transaction abort, the refresh behavior is consistent with the
doRefreshflag setting.src/lib/SoftHSM.cpp (3)
613-614: LGTM!The initialization correctly reads the configuration value with a sensible default that preserves backward compatibility.
1615-1615: Consistent parameter passing.The change correctly propagates the
doRefreshflag to the validity check.
1784-1784: Consistent implementation of configurable refresh behavior.All the
isValid()calls have been systematically updated to pass thedoRefreshparameter. The changes maintain appropriate error codes for different contexts (object vs key operations) and preserve the existing error handling logic.Also applies to: 1832-1832, 1856-1856, 1903-1903, 2173-2173, 2421-2421, 2902-2902, 3151-3151, 3802-3802, 3953-3953, 4105-4105, 4931-4931, 5083-5083, 6519-6519, 6561-6561, 6987-6987, 7287-7287, 10393-10393, 10725-10725, 11079-11079, 11605-11605
Before this commit the object store for a file token was always refreshed by reading
the file of the token every time an object of the token was fetched.
Now the HSM may be configured not to refresh when fetching an object. But the
refresh will still be done after an application gets a handle for an object.
The reason for this change is that the CPU time consumed by the reading may not
be negligible for some HW.
Summary by CodeRabbit
New Features
objectstore.readrefresh, with documentation and example usage.Bug Fixes
Documentation
objectstore.readrefreshoption.Tests