@@ -266,11 +266,6 @@ Connector<BUFFER, NetProvider>::waitAll(Connection<BUFFER, NetProvider> &conn,
266266 timer.start ();
267267 size_t last_not_ready = 0 ;
268268 while (!conn.hasError ()) {
269- if (m_NetProvider.wait (timer.timeLeft ()) != 0 ) {
270- conn.setError (std::string (" Failed to poll: " ) +
271- strerror (errno), errno);
272- return -1 ;
273- }
274269 if (connectionDecodeResponses (conn) != 0 )
275270 return -1 ;
276271 bool finish = true ;
@@ -283,6 +278,11 @@ Connector<BUFFER, NetProvider>::waitAll(Connection<BUFFER, NetProvider> &conn,
283278 }
284279 if (finish)
285280 return 0 ;
281+ if (m_NetProvider.wait (timer.timeLeft ()) != 0 ) {
282+ conn.setError (std::string (" Failed to poll: " ) +
283+ strerror (errno), errno);
284+ return -1 ;
285+ }
286286 if (timer.isExpired ())
287287 break ;
288288 }
@@ -325,15 +325,15 @@ Connector<BUFFER, NetProvider>::waitCount(Connection<BUFFER, NetProvider> &conn,
325325 timer.start ();
326326 size_t ready_futures = conn.getFutureCount ();
327327 while (!conn.hasError ()) {
328+ if (connectionDecodeResponses (conn) != 0 )
329+ return -1 ;
330+ if ((conn.getFutureCount () - ready_futures) >= future_count)
331+ return 0 ;
328332 if (m_NetProvider.wait (timer.timeLeft ()) != 0 ) {
329333 conn.setError (std::string (" Failed to poll: " ) +
330334 strerror (errno), errno);
331335 return -1 ;
332336 }
333- if (connectionDecodeResponses (conn) != 0 )
334- return -1 ;
335- if ((conn.getFutureCount () - ready_futures) >= future_count)
336- return 0 ;
337337 if (timer.isExpired ())
338338 break ;
339339 }
0 commit comments