Make boot_uuid change in event loops when it changes

We were seeing any event loops created before the UUID changes staying
the same.  This defeats the purpose.  This is especially true for the
simulated network bridge which uses an event loop to get the boot UUID,
and wants to observe when it changes.

The boot UUID shouldn't change in any other conditions, so this won't
have an effect on anything else.

Change-Id: Idfa8f36e8d0e4ba964d09bf2170cbbffb17b8276
diff --git a/aos/events/event_loop.cc b/aos/events/event_loop.cc
index 8d01549..08fa7fd 100644
--- a/aos/events/event_loop.cc
+++ b/aos/events/event_loop.cc
@@ -79,9 +79,8 @@
 
 PhasedLoopHandler::~PhasedLoopHandler() {}
 
-EventLoop::EventLoop(const Configuration *configuration, UUID boot_uuid)
-    : boot_uuid_(boot_uuid),
-      timing_report_(flatbuffers::DetachedBuffer()),
+EventLoop::EventLoop(const Configuration *configuration)
+    : timing_report_(flatbuffers::DetachedBuffer()),
       configuration_(configuration) {}
 
 EventLoop::~EventLoop() {
diff --git a/aos/events/event_loop.h b/aos/events/event_loop.h
index 3916ce4..0534242 100644
--- a/aos/events/event_loop.h
+++ b/aos/events/event_loop.h
@@ -474,7 +474,7 @@
 
 class EventLoop {
  public:
-  EventLoop(const Configuration *configuration, UUID boot_uuid);
+  EventLoop(const Configuration *configuration);
 
   virtual ~EventLoop();
 
@@ -655,7 +655,7 @@
   virtual int NumberBuffers(const Channel *channel) = 0;
 
   // Returns the boot UUID.
-  const UUID &boot_uuid() { return boot_uuid_; }
+  virtual const UUID &boot_uuid() const = 0;
 
  protected:
   // Sets the name of the event loop.  This is the application name.
@@ -736,8 +736,6 @@
   // If true, don't send AOS_LOG to /aos
   bool skip_logger_ = false;
 
-  UUID boot_uuid_;
-
  private:
   virtual pid_t GetTid() = 0;
 
diff --git a/aos/events/shm_event_loop.cc b/aos/events/shm_event_loop.cc
index 2a0d332..39ce8db 100644
--- a/aos/events/shm_event_loop.cc
+++ b/aos/events/shm_event_loop.cc
@@ -222,7 +222,8 @@
 }  // namespace
 
 ShmEventLoop::ShmEventLoop(const Configuration *configuration)
-    : EventLoop(configuration, UUID::BootUUID()),
+    : EventLoop(configuration),
+      boot_uuid_(UUID::BootUUID()),
       shm_base_(FLAGS_shm_base),
       name_(FLAGS_application_name),
       node_(MaybeMyNode(configuration)) {
diff --git a/aos/events/shm_event_loop.h b/aos/events/shm_event_loop.h
index 148a206..b76b4fe 100644
--- a/aos/events/shm_event_loop.h
+++ b/aos/events/shm_event_loop.h
@@ -78,6 +78,7 @@
   const Node *node() const override { return node_; }
 
   int priority() const override { return priority_; }
+  const UUID &boot_uuid() const override { return boot_uuid_; }
 
   // Returns the epoll loop used to run the event loop.
   internal::EPoll *epoll() { return &epoll_; }
@@ -136,6 +137,8 @@
   absl::Span<const char> GetShmFetcherPrivateMemory(
       const aos::RawFetcher *fetcher) const;
 
+  const UUID boot_uuid_;
+
   // Capture the --shm_base flag at construction time.  This makes it much
   // easier to make different shared memory regions for doing things like
   // multi-node tests.
diff --git a/aos/events/simulated_event_loop.cc b/aos/events/simulated_event_loop.cc
index f59fc23..e2aebb0 100644
--- a/aos/events/simulated_event_loop.cc
+++ b/aos/events/simulated_event_loop.cc
@@ -462,8 +462,7 @@
       std::vector<std::pair<EventLoop *, std::function<void(bool)>>>
           *raw_event_loops,
       const Node *node, pid_t tid)
-      : EventLoop(CHECK_NOTNULL(configuration),
-                  node_event_loop_factory->boot_uuid()),
+      : EventLoop(CHECK_NOTNULL(configuration)),
         scheduler_(scheduler),
         node_event_loop_factory_(node_event_loop_factory),
         channels_(channels),
@@ -575,6 +574,10 @@
 
   int NumberBuffers(const Channel *channel) override;
 
+  const UUID &boot_uuid() const override {
+    return node_event_loop_factory_->boot_uuid();
+  }
+
  private:
   friend class SimulatedTimerHandler;
   friend class SimulatedPhasedLoopHandler;