| 186 | }; |
| 187 | |
| 188 | inline void ServeRequest(TVersionedServiceMap& mp, IRequestRef req) { |
| 189 | if (!req) { |
| 190 | return; |
| 191 | } |
| 192 | |
| 193 | const TStringBuf name = req->Service(); |
| 194 | TSrvs::const_iterator it = mp.Srvs.find(name); |
| 195 | |
| 196 | if (Y_UNLIKELY(it == mp.Srvs.end())) { |
| 197 | if (UpdateServices(mp.Srvs, mp.Version)) { |
| 198 | it = mp.Srvs.find(name); |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | if (Y_UNLIKELY(it == mp.Srvs.end())) { |
| 203 | it = mp.Srvs.find(TStringBuf("*")); |
| 204 | } |
| 205 | |
| 206 | if (Y_UNLIKELY(it == mp.Srvs.end())) { |
| 207 | req->SendError(IRequest::NotExistService); |
| 208 | } else { |
| 209 | try { |
| 210 | it->second->ServeRequest(req); |
| 211 | } catch (...) { |
| 212 | Cdbg << CurrentExceptionMessage() << Endl; |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | inline bool UpdateServices(TSrvs& srvs, i64& version) const { |
| 218 | if (SelfVersion_.load() == version) { |
nothing calls this directly
no test coverage detected