summaryrefslogtreecommitdiff
path: root/meta-ibs/meta-cp2-5422/recipes-phosphor/network/phosphor-snmp/0001-main-Use-sdeventplus.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-ibs/meta-cp2-5422/recipes-phosphor/network/phosphor-snmp/0001-main-Use-sdeventplus.patch')
-rw-r--r--meta-ibs/meta-cp2-5422/recipes-phosphor/network/phosphor-snmp/0001-main-Use-sdeventplus.patch123
1 files changed, 123 insertions, 0 deletions
diff --git a/meta-ibs/meta-cp2-5422/recipes-phosphor/network/phosphor-snmp/0001-main-Use-sdeventplus.patch b/meta-ibs/meta-cp2-5422/recipes-phosphor/network/phosphor-snmp/0001-main-Use-sdeventplus.patch
new file mode 100644
index 0000000000..e38befa7d6
--- /dev/null
+++ b/meta-ibs/meta-cp2-5422/recipes-phosphor/network/phosphor-snmp/0001-main-Use-sdeventplus.patch
@@ -0,0 +1,123 @@
+From d07ee811792a8440fc0cc99d7f51aa4121e50928 Mon Sep 17 00:00:00 2001
+From: "Andrey V.Kosteltsev" <AKosteltsev@IBS.RU>
+Date: Sun, 17 Jul 2022 12:25:14 +0300
+Subject: [PATCH 1/3] main: Use sdeventplus
+
+Makes use sdeventplus instead custom wrapper around the sd_event library calls.
+
+Signed-off-by: Andrey V.Kosteltsev <AKosteltsev@IBS.RU>
+---
+ meson.build | 8 +++++++-
+ snmp_main.cpp | 27 ++++-----------------------
+ subprojects/sdeventplus.wrap | 6 ++++++
+ 3 files changed, 17 insertions(+), 24 deletions(-)
+ create mode 100644 subprojects/sdeventplus.wrap
+
+diff --git a/meson.build b/meson.build
+index 73ca4a6..8a82752 100644
+--- a/meson.build
++++ b/meson.build
+@@ -17,6 +17,7 @@ conf_data.set_quoted('SNMP_CONF_PERSIST_PATH', '/var/lib/phosphor-snmp/managers/
+ conf_data.set('CLASS_VERSION', 1)
+
+ sdbusplus_dep = dependency('sdbusplus')
++sdeventplus_dep = dependency('sdeventplus')
+ phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
+ phosphor_logging_dep = dependency('phosphor-logging')
+ libsystemd_dep = dependency('libsystemd')
+@@ -30,6 +31,7 @@ deps = [
+ phosphor_dbus_interfaces_dep,
+ phosphor_logging_dep,
+ sdbusplus_dep,
++ sdeventplus_dep,
+ ]
+
+ sources = [
+@@ -55,6 +57,7 @@ executable(
+
+ libsnmp_deps = [
+ sdbusplus_dep,
++ sdeventplus_dep,
+ phosphor_logging_dep,
+ phosphor_dbus_interfaces_dep,
+ netsnmp_dep,
+@@ -85,7 +88,10 @@ import('pkgconfig').generate(
+ libsnmp_lib,
+ name: meson.project_name(),
+ version: meson.project_version(),
+- requires: sdbusplus_dep,
++ requires: [
++ sdbusplus_dep,
++ sdeventplus_dep,
++ ],
+ description: 'Phosphor snmp utilities',
+ )
+
+diff --git a/snmp_main.cpp b/snmp_main.cpp
+index be4bea1..ab3c4b6 100644
+--- a/snmp_main.cpp
++++ b/snmp_main.cpp
+@@ -4,38 +4,19 @@
+
+ #include <phosphor-logging/lg2.hpp>
+ #include <sdbusplus/bus.hpp>
++#include <sdeventplus/event.hpp>
+ #include <sdbusplus/server/manager.hpp>
+
+ #include <memory>
+
+-/* Need a custom deleter for freeing up sd_event */
+-struct EventDeleter
+-{
+- void operator()(sd_event* event) const
+- {
+- sd_event_unref(event);
+- }
+-};
+-
+-using EventPtr = std::unique_ptr<sd_event, EventDeleter>;
+-
+ int main(int /*argc*/, char** /*argv[]*/)
+ {
+ auto bus = sdbusplus::bus::new_default();
+
+- sd_event* event = nullptr;
+- auto r = sd_event_default(&event);
+- if (r < 0)
+- {
+- lg2::error("Error creating a default sd_event handler: {RC}", "RC", r);
+- return r;
+- }
+-
+- EventPtr eventPtr{event};
+- event = nullptr;
++ auto event = sdeventplus::Event::get_default();
+
+ // Attach the bus to sd_event to service user requests
+- bus.attach_event(eventPtr.get(), SD_EVENT_PRIORITY_NORMAL);
++ bus.attach_event(event.get(), SD_EVENT_PRIORITY_NORMAL);
+
+ // Add sdbusplus Object Manager for the 'root' path of the snmp.
+ sdbusplus::server::manager::manager objManager(bus, OBJ_NETWORK_SNMP);
+@@ -46,5 +27,5 @@ int main(int /*argc*/, char** /*argv[]*/)
+
+ manager->restoreClients();
+
+- return sd_event_loop(eventPtr.get());
++ return event.loop();
+ }
+diff --git a/subprojects/sdeventplus.wrap b/subprojects/sdeventplus.wrap
+new file mode 100644
+index 0000000..f871ac0
+--- /dev/null
++++ b/subprojects/sdeventplus.wrap
+@@ -0,0 +1,6 @@
++[wrap-git]
++url = https://github.com/openbmc/sdeventplus.git
++revision = HEAD
++
++[provide]
++sdeventplus = sdeventplus_dep
+--
+2.35.1
+