1
0
mirror of https://github.com/UzixLS/picocom.git synced 2025-07-19 07:21:18 +03:00

Changed TCSAFLUSH to TCSANOW

In all cases the pattern was tcflush(fd, TCIOFLUSH) followed by
tcsetattr(fd, TCSAFLUSH, ...). The problem was that, for some drivers,
tcflush() was apparently doing nothing, so tcsetattr() might hang
forever waiting for the output buffers to drain (possible if flow
control is enabled). Replaced tcflush(fd, TCSAFLUSH), with tcsetattr(fd,
TCSANOW) which, after a tcflush() should anyway be equivalent.
This commit is contained in:
Nick Patavalis
2015-08-25 15:00:18 +03:00
parent f6f71b6f5b
commit d21c94eb75
3 changed files with 25 additions and 19 deletions

18
term.c
View File

@ -354,7 +354,7 @@ term_exitfunc (void)
continue;
tcflush(term.fd[i], TCIOFLUSH);
do {
r = tcsetattr(term.fd[i], TCSAFLUSH, &term.origtermios[i]);
r = tcsetattr(term.fd[i], TCSANOW, &term.origtermios[i]);
} while ( r < 0 && errno == EINTR );
if ( r < 0 ) {
char *tname;
@ -386,7 +386,7 @@ term_lib_init (void)
continue;
tcflush(term.fd[i], TCIOFLUSH);
do {
r = tcsetattr(term.fd[i], TCSAFLUSH, &term.origtermios[i]);
r = tcsetattr(term.fd[i], TCSANOW, &term.origtermios[i]);
} while ( r < 0 && errno == EINTR );
if ( r < 0 ) {
char *tname;
@ -482,7 +482,7 @@ term_remove(int fd)
rval = -1;
break;
}
r = tcsetattr(term.fd[i], TCSAFLUSH, &term.origtermios[i]);
r = tcsetattr(term.fd[i], TCSANOW, &term.origtermios[i]);
if ( r < 0 ) {
term_errno = TERM_ESETATTR;
rval = -1;
@ -535,7 +535,7 @@ term_replace (int oldfd, int newfd)
break;
}
r = tcsetattr(newfd, TCSAFLUSH, &term.currtermios[i]);
r = tcsetattr(newfd, TCSANOW, &term.currtermios[i]);
if ( r < 0 ) {
term_errno = TERM_ESETATTR;
rval = -1;
@ -578,7 +578,7 @@ term_reset (int fd)
rval = -1;
break;
}
r = tcsetattr(term.fd[i], TCSAFLUSH, &term.origtermios[i]);
r = tcsetattr(term.fd[i], TCSANOW, &term.origtermios[i]);
if ( r < 0 ) {
term_errno = TERM_ESETATTR;
rval = -1;
@ -653,9 +653,11 @@ term_refresh (int fd)
/***************************************************************************/
int
term_apply (int fd)
term_apply (int fd, int now)
{
int rval, r, i;
int when, rval, r, i;
when = now ? TCSANOW : TCSAFLUSH;
rval = 0;
@ -667,7 +669,7 @@ term_apply (int fd)
break;
}
r = tcsetattr(term.fd[i], TCSAFLUSH, &term.nexttermios[i]);
r = tcsetattr(term.fd[i], when, &term.nexttermios[i]);
if ( r < 0 ) {
term_errno = TERM_ESETATTR;
rval = -1;