nvidia-gpu: Fix a number of object lifetime issues
Moves all subsensors and objects treated as shared_ptrs
to be using shared_from_this. This way, if there's an object lifetime
issue we don't segfault.
Also separates construction and asio init for NvidiaSmaDevice
so that when we bind to this, its valid after we leave the ctor
Change-Id: I8e3115bc276d2e0eaac0b1dc9a9d2c46e6751d4b
Signed-off-by: Marc Olberding <molberding@nvidia.com>
diff --git a/src/nvidia-gpu/NvidiaSmaDevice.hpp b/src/nvidia-gpu/NvidiaSmaDevice.hpp
index fc78de2..2c74892 100644
--- a/src/nvidia-gpu/NvidiaSmaDevice.hpp
+++ b/src/nvidia-gpu/NvidiaSmaDevice.hpp
@@ -20,7 +20,7 @@
 #include <memory>
 #include <string>
 
-class SmaDevice
+class SmaDevice : public std::enable_shared_from_this<SmaDevice>
 {
   public:
     SmaDevice(const SensorConfigs& configs, const std::string& name,
@@ -35,6 +35,8 @@
         return path;
     }
 
+    void init();
+
   private:
     void makeSensors();