Fix coredump during subscription
Commit 4b712a29debc1a0860cc04850b262203cad402a5 [1] a bug on missing the
subscription copy from user persistent data when subscription object is
created, and it may cause a bmcweb crash.
Tested:
- Create subscription (e.g. Redfish Event Listener)
- Create a dump
```
curl -k -X POST "https://${bmc}/redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.CollectDiagnosticData" \
-H "Content-Type: application/json" -d '{"DiagnosticDataType": "Manager"}'
curl: (56) OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 0
```
BMC journal will contain like
```
Oct 14 21:49:20 p10bmc bmcwebd[287]: terminate called after throwing an instance of 'std::bad_weak_ptr'
Oct 14 21:49:20 p10bmc bmcwebd[287]: what(): bad_weak_ptr
Oct 14 21:49:21 p10bmc systemd[1]: bmcweb.service: Main process exited, code=dumped, status=6/ABRT
Oct 14 21:49:21 p10bmc systemd[1]: bmcweb.service: Failed with result 'core-dump'
```
[1] 4b712a29debc1a0860cc04850b262203cad402a5
Change-Id: I58479bb5e1f203fec60ad0971f0c750ab5695f14
Signed-off-by: Myung Bae <myungbae@us.ibm.com>
diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp
index ca1e713..cad410b 100644
--- a/redfish-core/lib/event_service.hpp
+++ b/redfish-core/lib/event_service.hpp
@@ -432,7 +432,8 @@
}
std::shared_ptr<Subscription> subValue =
- std::make_shared<Subscription>(*url, app.ioContext());
+ std::make_shared<Subscription>(
+ persistent_data::UserSubscription{}, *url, app.ioContext());
subValue->userSub.destinationUrl = std::move(*url);