@@ -309,16 +309,20 @@ Connector<BUFFER, NetProvider>::waitAll(Connection<BUFFER, NetProvider> &conn,
309309 const std::vector<rid_t > &futures,
310310 int timeout)
311311{
312+ size_t last_not_ready = 0 ;
313+ bool finish = false ;
314+ if (connectionCheckResponsesReadiness (conn, futures, &last_not_ready, &finish) != 0 )
315+ return -1 ;
316+ if (finish)
317+ return 0 ;
312318 Timer timer{timeout};
313319 timer.start ();
314- size_t last_not_ready = 0 ;
315320 while (!conn.hasError ()) {
316321 if (m_NetProvider.wait (timer.timeLeft ()) != 0 ) {
317322 conn.setError (std::string (" Failed to poll: " ) +
318323 strerror (errno), errno);
319324 return -1 ;
320325 }
321- bool finish = false ;
322326 if (connectionCheckResponsesReadiness (conn, futures, &last_not_ready, &finish) != 0 )
323327 return -1 ;
324328 if (finish)
@@ -361,17 +365,21 @@ int
361365Connector<BUFFER, NetProvider>::waitCount(Connection<BUFFER, NetProvider> &conn,
362366 size_t future_count, int timeout)
363367{
364- Timer timer{timeout};
365- timer.start ();
366368 size_t ready_futures = conn.getFutureCount ();
367369 size_t expected_future_count = ready_futures + future_count;
370+ bool finish = false ;
371+ if (connectionCheckCountResponsesReadiness (conn, expected_future_count, &finish) != 0 )
372+ return -1 ;
373+ if (finish)
374+ return 0 ;
375+ Timer timer{timeout};
376+ timer.start ();
368377 while (!conn.hasError ()) {
369378 if (m_NetProvider.wait (timer.timeLeft ()) != 0 ) {
370379 conn.setError (std::string (" Failed to poll: " ) +
371380 strerror (errno), errno);
372381 return -1 ;
373382 }
374- bool finish = false ;
375383 if (connectionCheckCountResponsesReadiness (conn, expected_future_count, &finish) != 0 )
376384 return -1 ;
377385 if (finish)
0 commit comments