Skip to content

Commit

Permalink
Support networks with high latency
Browse files Browse the repository at this point in the history
  • Loading branch information
p-gen committed Sep 1, 2020
1 parent 37906c7 commit 2a801c7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 33 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* -N and -U options can now have multiple arguments.
* Fuzzy and substring searches now ignore leading and trailing blanks.
* Unicode codepoints can now be entered using the new \U notation.
* smenu has been optimized to support networks with high latency.
* Misc:
+ A note in the README to thank the packagers has been added.
+ The code has been adjusted to conform to C99.
Expand Down
56 changes: 24 additions & 32 deletions smenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -3381,17 +3381,17 @@ disp_message(ll_t * message_lines_list, long message_max_width,
long offset;
wchar_t * w;

sigset_t mask;

win->message_lines = 0;

/* Disarm the periodic timer to prevent the interruptions to corrupt */
/* screen by altering the timing of the decoding of the terminfo */
/* capabilities de */
/* """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" */
periodic_itv.it_value.tv_sec = 0;
periodic_itv.it_value.tv_usec = 0;
periodic_itv.it_interval.tv_sec = 0;
periodic_itv.it_interval.tv_usec = 0;
setitimer(ITIMER_REAL, &periodic_itv, NULL);
/* Deactivate the periodic timer to prevent the interruptions to corrupt */
/* screen by altering the timing of the decoding of the terminfo */
/* capabilities. */
/* """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" */
sigemptyset(&mask);
sigaddset(&mask, SIGALRM);
sigprocmask(SIG_BLOCK, &mask, NULL);

/* Do nothing if there is no message to display */
/* """""""""""""""""""""""""""""""""""""""""""" */
Expand Down Expand Up @@ -3464,13 +3464,9 @@ disp_message(ll_t * message_lines_list, long message_max_width,

free(buf);

/* Re-arm the periodic timer */
/* """"""""""""""""""""""""" */
periodic_itv.it_value.tv_sec = 0;
periodic_itv.it_value.tv_usec = TICK;
periodic_itv.it_interval.tv_sec = 0;
periodic_itv.it_interval.tv_usec = TICK;
setitimer(ITIMER_REAL, &periodic_itv, NULL);
/* Re-enable the periodic timer. */
/* """"""""""""""""""""""""""""" */
sigprocmask(SIG_UNBLOCK, &mask, NULL);
}

/* ============================ */
Expand All @@ -3488,15 +3484,15 @@ disp_lines(win_t * win, toggle_t * toggle, long current, long count,
long len;
long display_bar;

/* Disarm the periodic timer to prevent the interruptions to corrupt */
/* screen by altering the timing of the decoding of the terminfo */
/* capabilities de */
/* """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" */
periodic_itv.it_value.tv_sec = 0;
periodic_itv.it_value.tv_usec = 0;
periodic_itv.it_interval.tv_sec = 0;
periodic_itv.it_interval.tv_usec = 0;
setitimer(ITIMER_REAL, &periodic_itv, NULL);
sigset_t mask;

/* Disable the periodic timer to prevent the interruptions to corrupt */
/* screen by altering the timing of the decoding of the terminfo */
/* capabilities. */
/* """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" */
sigemptyset(&mask);
sigaddset(&mask, SIGALRM);
sigprocmask(SIG_BLOCK, &mask, NULL);

scroll_symbol[0] = ' ';
scroll_symbol[1] = '\0';
Expand Down Expand Up @@ -3724,13 +3720,9 @@ disp_lines(win_t * win, toggle_t * toggle, long current, long count,
/* """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" */
tputs(TPARM1(restore_cursor), 1, outch);

/* Re-arm the periodic timer */
/* """"""""""""""""""""""""" */
periodic_itv.it_value.tv_sec = 0;
periodic_itv.it_value.tv_usec = TICK;
periodic_itv.it_interval.tv_sec = 0;
periodic_itv.it_interval.tv_usec = TICK;
setitimer(ITIMER_REAL, &periodic_itv, NULL);
/* Re-enable the periodic timer */
/* """""""""""""""""""""""""""" */
sigprocmask(SIG_UNBLOCK, &mask, NULL);

return lines_disp;
}
Expand Down
2 changes: 1 addition & 1 deletion smenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ struct termios old_in_attrs;

/* Interval timers used */
/* """""""""""""""""""" */
struct itimerval periodic_itv; /* refresh rate for the timeout counter */
struct itimerval periodic_itv; /* refresh rate for the timeout counter. */

int help_timer = -1;
int winch_timer = -1;
Expand Down

0 comments on commit 2a801c7

Please sign in to comment.