Skip to content

Commit

Permalink
Increase delay before displaying "waiting for data" message
Browse files Browse the repository at this point in the history
from 10 ms to 500 ms.

Fix logic errors in determining poll timeout:
1. poll should not block if in F command, and waiting message
   is not displayed, and --follow-name is not set.
2. poll should block if not in F command , and waiting message
   is displayed, and --follow-name is set.
  • Loading branch information
gwsw committed Feb 26, 2023
1 parent dff21e2 commit 4b674dd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion os.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ static int use_poll = TRUE;
#define LONG_JUMP longjmp
#endif

/* Milliseconds to wait for data before displaying "waiting for data" message. */
#define WAITING_FOR_DATA_DELAY 500

public int reading;
public int waiting_for_data;
public int consecutive_nulls = 0;
Expand Down Expand Up @@ -104,7 +107,7 @@ public void init_poll(void)
static int check_poll(int fd, int tty)
{
struct pollfd poller[2] = { { fd, POLLIN, 0 }, { tty, POLLIN, 0 } };
int timeout = ((waiting_for_data || scanning_eof) && follow_mode != FOLLOW_NAME) ? -1 : 10;
int timeout = (waiting_for_data && !(scanning_eof && follow_mode == FOLLOW_NAME)) ? -1 : WAITING_FOR_DATA_DELAY;
poll(poller, 2, timeout);
#if LESSTEST
if (ttyin_name == NULL) /* Check for ^X only on a real tty. */
Expand Down

0 comments on commit 4b674dd

Please sign in to comment.