Split out tty and shared_info stuff into their own headers and use throughout.
Include sys/termios.h for files which need it. * tty.h: New file. * shared_info.h: New file. * fhandler.h: Move inline methods that rely on tty stuff to fhandler_console.cc. * fhandler_tty.cc (fhandler_pty_master::process_slave_output): Set output_done_event immediately after reading data to speed up tty output processing. (process_output): Set write_error to errno or zero. (fhandler_tty_slave::write): Check previous write error prior to writing to slave end of pipe. This allows tty output to be slightly less synchronous. * fhandler_console.cc (fhandler_console::tcsetpgrp): Moved here from fhandler.h. (fhandler_console::set_input_state): Ditto.
This commit is contained in:
@ -23,6 +23,8 @@ details. */
|
||||
#include "sigproc.h"
|
||||
#include "pinfo.h"
|
||||
#include "cygheap.h"
|
||||
#include "tty.h"
|
||||
#include "shared_info.h"
|
||||
|
||||
/* Tty master stuff */
|
||||
|
||||
@ -285,14 +287,12 @@ fhandler_pty_master::process_slave_output (char *buf, size_t len, int pktmode_on
|
||||
}
|
||||
|
||||
termios_printf ("bytes read %u", n);
|
||||
get_ttyp ()->write_error = 0;
|
||||
if (output_done_event != NULL)
|
||||
SetEvent (output_done_event);
|
||||
|
||||
if (get_ttyp ()->ti.c_lflag & FLUSHO)
|
||||
{
|
||||
get_ttyp ()->write_retval = n;
|
||||
if (output_done_event != NULL)
|
||||
SetEvent (output_done_event);
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
|
||||
char *optr;
|
||||
optr = buf;
|
||||
@ -389,8 +389,7 @@ process_output (void *)
|
||||
ExitThread (0);
|
||||
}
|
||||
n = tty_master->console->write ((void *) buf, (size_t) n);
|
||||
tty_master->get_ttyp ()->write_retval = n == -1 ? -get_errno () : n;
|
||||
SetEvent (tty_master->output_done_event);
|
||||
tty_master->get_ttyp ()->write_error = n == -1 ? get_errno () : 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -554,6 +553,16 @@ fhandler_tty_slave::write (const void *ptr, size_t len)
|
||||
ptr = (char *) ptr + n;
|
||||
len -= n;
|
||||
|
||||
/* Previous write may have set write_error to != 0. Check it here.
|
||||
This is less than optimal, but the alternative slows down tty
|
||||
writes enormously. */
|
||||
if (get_ttyp ()->write_error)
|
||||
{
|
||||
set_errno (get_ttyp ()->write_error);
|
||||
towrite = (DWORD) -1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (WriteFile (get_output_handle (), buf, n, &n, NULL) == FALSE)
|
||||
{
|
||||
DWORD err = GetLastError ();
|
||||
@ -577,13 +586,6 @@ fhandler_tty_slave::write (const void *ptr, size_t len)
|
||||
rc = WaitForSingleObject (output_done_event, x);
|
||||
termios_printf("waited %d ms for output_done_event, WFSO %d", x, rc);
|
||||
}
|
||||
|
||||
if (get_ttyp ()->write_retval < 0)
|
||||
{
|
||||
set_errno (-get_ttyp ()->write_retval);
|
||||
towrite = (DWORD) -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
release_output_mutex ();
|
||||
return towrite;
|
||||
@ -931,12 +933,7 @@ fhandler_pty_master::write (const void *ptr, size_t len)
|
||||
int
|
||||
fhandler_pty_master::read (void *ptr, size_t len)
|
||||
{
|
||||
int x = process_slave_output ((char *) ptr, len, pktmode);
|
||||
|
||||
if (output_done_event != NULL)
|
||||
SetEvent (output_done_event);
|
||||
|
||||
return x;
|
||||
return process_slave_output ((char *) ptr, len, pktmode);
|
||||
}
|
||||
|
||||
int
|
||||
|
Reference in New Issue
Block a user