File tree 1 file changed +13
-3
lines changed
1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -95,7 +95,8 @@ class Config : public Logger::Loggable<Logger::Id::http> {
95
95
Upstream::ClusterManager& cm_;
96
96
std::string forward_attributes_;
97
97
MixerConfig mixer_config_;
98
- std::shared_ptr<HttpControl> http_control_;
98
+ std::mutex map_mutex_;
99
+ std::map<std::thread::id, std::shared_ptr<HttpControl>> http_control_map_;
99
100
100
101
public:
101
102
Config (const Json::Object& config, Server::Instance& server)
@@ -108,11 +109,20 @@ class Config : public Logger::Loggable<Logger::Id::http> {
108
109
Base64::encode (serialized_str.c_str (), serialized_str.size ());
109
110
log ().debug (" Mixer forward attributes set: " , serialized_str);
110
111
}
112
+ }
111
113
112
- http_control_ = std::make_shared<HttpControl>(mixer_config_, cm_);
114
+ std::shared_ptr<HttpControl> http_control () {
115
+ std::thread::id id = std::this_thread::get_id ();
116
+ std::lock_guard<std::mutex> lock (map_mutex_);
117
+ auto it = http_control_map_.find (id);
118
+ if (it != http_control_map_.end ()) {
119
+ return it->second ;
120
+ }
121
+ auto http_control = std::make_shared<HttpControl>(mixer_config_, cm_);
122
+ http_control_map_[id] = http_control;
123
+ return http_control;
113
124
}
114
125
115
- std::shared_ptr<HttpControl> http_control () { return http_control_; }
116
126
const std::string& forward_attributes () const { return forward_attributes_; }
117
127
};
118
128
You can’t perform that action at this time.
0 commit comments