@@ -4539,20 +4539,30 @@ threadRun(void *arg)
4539
4539
* or it's time to print a progress report. Update input_mask to show
4540
4540
* which client(s) received data.
4541
4541
*/
4542
- if (min_usec > 0 && maxsock != -1 )
4542
+ if (min_usec > 0 )
4543
4543
{
4544
- int nsocks ; /* return from select(2) */
4544
+ int nsocks = 0 ; /* return from select(2) if called */
4545
4545
4546
4546
if (min_usec != PG_INT64_MAX )
4547
4547
{
4548
- struct timeval timeout ;
4548
+ if (maxsock != -1 )
4549
+ {
4550
+ struct timeval timeout ;
4549
4551
4550
- timeout .tv_sec = min_usec / 1000000 ;
4551
- timeout .tv_usec = min_usec % 1000000 ;
4552
- nsocks = select (maxsock + 1 , & input_mask , NULL , NULL , & timeout );
4552
+ timeout .tv_sec = min_usec / 1000000 ;
4553
+ timeout .tv_usec = min_usec % 1000000 ;
4554
+ nsocks = select (maxsock + 1 , & input_mask , NULL , NULL , & timeout );
4555
+ }
4556
+ else /* nothing active, simple sleep */
4557
+ {
4558
+ pg_usleep (min_usec );
4559
+ }
4553
4560
}
4554
- else
4561
+ else /* no explicit delay, select without timeout */
4562
+ {
4555
4563
nsocks = select (maxsock + 1 , & input_mask , NULL , NULL , NULL );
4564
+ }
4565
+
4556
4566
if (nsocks < 0 )
4557
4567
{
4558
4568
if (errno == EINTR )
@@ -4565,7 +4575,7 @@ threadRun(void *arg)
4565
4575
goto done ;
4566
4576
}
4567
4577
}
4568
- else
4578
+ else /* min_usec == 0, i.e. something needs to be executed */
4569
4579
{
4570
4580
/* If we didn't call select(), don't try to read any data */
4571
4581
FD_ZERO (& input_mask );
0 commit comments