@@ -4578,20 +4578,30 @@ threadRun(void *arg)
4578
4578
* or it's time to print a progress report. Update input_mask to show
4579
4579
* which client(s) received data.
4580
4580
*/
4581
- if (min_usec > 0 && maxsock != -1 )
4581
+ if (min_usec > 0 )
4582
4582
{
4583
- int nsocks ; /* return from select(2) */
4583
+ int nsocks = 0 ; /* return from select(2) if called */
4584
4584
4585
4585
if (min_usec != PG_INT64_MAX )
4586
4586
{
4587
- struct timeval timeout ;
4587
+ if (maxsock != -1 )
4588
+ {
4589
+ struct timeval timeout ;
4588
4590
4589
- timeout .tv_sec = min_usec / 1000000 ;
4590
- timeout .tv_usec = min_usec % 1000000 ;
4591
- nsocks = select (maxsock + 1 , & input_mask , NULL , NULL , & timeout );
4591
+ timeout .tv_sec = min_usec / 1000000 ;
4592
+ timeout .tv_usec = min_usec % 1000000 ;
4593
+ nsocks = select (maxsock + 1 , & input_mask , NULL , NULL , & timeout );
4594
+ }
4595
+ else /* nothing active, simple sleep */
4596
+ {
4597
+ pg_usleep (min_usec );
4598
+ }
4592
4599
}
4593
- else
4600
+ else /* no explicit delay, select without timeout */
4601
+ {
4594
4602
nsocks = select (maxsock + 1 , & input_mask , NULL , NULL , NULL );
4603
+ }
4604
+
4595
4605
if (nsocks < 0 )
4596
4606
{
4597
4607
if (errno == EINTR )
@@ -4604,7 +4614,7 @@ threadRun(void *arg)
4604
4614
goto done ;
4605
4615
}
4606
4616
}
4607
- else
4617
+ else /* min_usec == 0, i.e. something needs to be executed */
4608
4618
{
4609
4619
/* If we didn't call select(), don't try to read any data */
4610
4620
FD_ZERO (& input_mask );
0 commit comments