| 1143 | } |
| 1144 | |
| 1145 | void THttpRequest::Run(THttpRequestRef& req) { |
| 1146 | #ifdef DEBUG_STAT |
| 1147 | if ((++TDebugStat::RequestTotal & 0xFFF) == 0) { |
| 1148 | TDebugStat::Print(); |
| 1149 | } |
| 1150 | #endif |
| 1151 | try { |
| 1152 | while (!Canceled_) { |
| 1153 | THttpConnRef conn; |
| 1154 | if (HttpConnManager()->Get(conn, Addr_->Id)) { |
| 1155 | DBGOUT("Use connection from cache"); |
| 1156 | Conn_ = conn; //thread magic |
| 1157 | if (!conn->StartNextRequest(req)) { |
| 1158 | continue; //if use connection from cache, ignore write error and try another conn |
| 1159 | } |
| 1160 | } else { |
| 1161 | HttpConnManager()->CheckLimits(); //here throw exception if reach hard limit (or atexit() state) |
| 1162 | Conn_ = THttpConn::Create(HttpConnManager()->GetIOService()); |
| 1163 | TEndpoint ep(new NAddr::TAddrInfo(&*AddrIter_)); |
| 1164 | Conn_->StartRequest(req, ep, Addr_->Id, THttp2Options::SymptomSlowConnect); // can throw |
| 1165 | } |
| 1166 | break; |
| 1167 | } |
| 1168 | } catch (...) { |
| 1169 | Conn_.Reset(); |
| 1170 | throw; |
| 1171 | } |
| 1172 | } |
| 1173 | |
| 1174 | //it seems we have lost TCP SYN packet, create extra connection for decrease response time |
| 1175 | void THttpRequest::OnDetectSlowConnecting() { |
no test coverage detected