Repository: envoyproxy/envoy
File: source/server/hot_restart_impl.h (C/C++)

Code before:

    return true;
  }

  void unlock() ABSL_UNLOCK_FUNCTION() override {
    int rc = pthread_mutex_unlock(&mutex_);
    ASSERT(rc == 0);
  }

private:
  pthread_mutex_t& mutex_;
};

/**
 * Implementation of HotRestart built for Linux. Most of the "protocol" type logic is split out into
 * HotRestarting{Base,Parent,Child}. This class ties all that to shared memory and version logic.
 */
class HotRestartImpl : public HotRestart {
public:
  HotRestartImpl(uint32_t base_id, uint32_t restart_epoch, const std::string& socket_path,
                 mode_t socket_mode, bool skip_hot_restart_on_no_parent, bool skip_parent_stats);

  // Server::HotRestart
  void drainParentListeners() override;
  int duplicateParentListenSocket(const std::string& address, uint32_t worker_index,
                                  const std::string& network_namespace) override;
  void registerUdpForwardingListener(
      Network::Address::InstanceConstSharedPtr address,
      std::shared_ptr<Network::UdpListenerConfig> listener_config) override;
  OptRef<Network::ParentDrainedCallbackRegistrar> parentDrainedCallbackRegistrar() override;
  void initialize(Event::Dispatcher& dispatcher, Server::Instance& server) override;
  absl::optional<AdminShutdownResponse> sendParentAdminShutdownRequest() override;
  void sendParentTerminateRequest() override;
  ServerStatsFromParent mergeParentStatsIfAny(Stats::StoreRoot& stats_store) override;
  void shutdown() override;
  uint32_t baseId() override;
  std::string version() override;
  Thread::BasicLockable& logLock() override { return log_lock_; }
  Thread::BasicLockable& accessLogLock() override { return access_log_lock_; }
  bool isInitializing() const override;

  /**
   * envoy --hot_restart_version doesn't initialize Envoy, but computes the version string
   * based on the configured options.
   */
  static std::string hotRestartVersion();

private:
  friend class HotRestartUdpForwardingTestHelper;
  uint32_t base_id_;
  uint32_t scaled_base_id_;

Review comment (suggestion):
```suggestion
                                  absl::string_view network_namespace) override;
```

Code after:

    return true;
  }

  void unlock() ABSL_UNLOCK_FUNCTION() override {
    int rc = pthread_mutex_unlock(&mutex_);
    ASSERT(rc == 0);
  }

private:
  pthread_mutex_t& mutex_;
};

/**
 * Implementation of HotRestart built for Linux. Most of the "protocol" type logic is split out into
 * HotRestarting{Base,Parent,Child}. This class ties all that to shared memory and version logic.
 */
class HotRestartImpl : public HotRestart {
public:
  HotRestartImpl(uint32_t base_id, uint32_t restart_epoch, const std::string& socket_path,
                 mode_t socket_mode, bool skip_hot_restart_on_no_parent, bool skip_parent_stats);

  // Server::HotRestart
  void drainParentListeners() override;
  int duplicateParentListenSocket(const std::string& address, uint32_t worker_index,
                                  absl::string_view network_namespace) override;
  void registerUdpForwardingListener(
      Network::Address::InstanceConstSharedPtr address,
      std::shared_ptr<Network::UdpListenerConfig> listener_config) override;
  OptRef<Network::ParentDrainedCallbackRegistrar> parentDrainedCallbackRegistrar() override;
  void initialize(Event::Dispatcher& dispatcher, Server::Instance& server) override;
  absl::optional<AdminShutdownResponse> sendParentAdminShutdownRequest() override;
  void sendParentTerminateRequest() override;
  ServerStatsFromParent mergeParentStatsIfAny(Stats::StoreRoot& stats_store) override;
  void shutdown() override;
  uint32_t baseId() override;
  std::string version() override;
  Thread::BasicLockable& logLock() override { return log_lock_; }
  Thread::BasicLockable& accessLogLock() override { return access_log_lock_; }
  bool isInitializing() const override;

  /**
   * envoy --hot_restart_version doesn't initialize Envoy, but computes the version string
   * based on the configured options.
   */
  static std::string hotRestartVersion();

private:
  friend class HotRestartUdpForwardingTestHelper;
  uint32_t base_id_;
  uint32_t scaled_base_id_;