mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 09:58:01 +00:00
Reading 4K at a time from a serial port turns out to be a bit
unfriendly in an interactive session, because at 19200 baud it takes
nearly two seconds to receive that much data, and as long as the
data is flowing continuously Windows waits until it has a full
buffer. So here's another annoying flag in the winhandl API, which
restricts reads to length 1 so that serial output shows up as it
appears.
(I tried this yesterday, but without the OVERLAPPED fix in r6826 it
behaved very erratically. It now seems solid.)
[originally from svn r6827]
[r6826 == 2aedc83f8d
]
This commit is contained in:
parent
2aedc83f8d
commit
a485923ae4
@ -102,6 +102,7 @@ static DWORD WINAPI handle_input_threadfunc(void *param)
|
|||||||
struct handle_input *ctx = (struct handle_input *) param;
|
struct handle_input *ctx = (struct handle_input *) param;
|
||||||
OVERLAPPED ovl, *povl;
|
OVERLAPPED ovl, *povl;
|
||||||
HANDLE oev;
|
HANDLE oev;
|
||||||
|
int readlen;
|
||||||
|
|
||||||
if (ctx->flags & HANDLE_FLAG_OVERLAPPED) {
|
if (ctx->flags & HANDLE_FLAG_OVERLAPPED) {
|
||||||
povl = &ovl;
|
povl = &ovl;
|
||||||
@ -110,12 +111,17 @@ static DWORD WINAPI handle_input_threadfunc(void *param)
|
|||||||
povl = NULL;
|
povl = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ctx->flags & HANDLE_FLAG_UNITBUFFER)
|
||||||
|
readlen = 1;
|
||||||
|
else
|
||||||
|
readlen = sizeof(ctx->buffer);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (povl) {
|
if (povl) {
|
||||||
memset(povl, 0, sizeof(OVERLAPPED));
|
memset(povl, 0, sizeof(OVERLAPPED));
|
||||||
povl->hEvent = oev;
|
povl->hEvent = oev;
|
||||||
}
|
}
|
||||||
ctx->readret = ReadFile(ctx->h, ctx->buffer, sizeof(ctx->buffer),
|
ctx->readret = ReadFile(ctx->h, ctx->buffer, readlen,
|
||||||
&ctx->len, povl);
|
&ctx->len, povl);
|
||||||
if (povl && !ctx->readret && GetLastError() == ERROR_IO_PENDING) {
|
if (povl && !ctx->readret && GetLastError() == ERROR_IO_PENDING) {
|
||||||
WaitForSingleObject(povl->hEvent, INFINITE);
|
WaitForSingleObject(povl->hEvent, INFINITE);
|
||||||
|
@ -241,7 +241,8 @@ static const char *serial_init(void *frontend_handle, void **backend_handle,
|
|||||||
HANDLE_FLAG_OVERLAPPED);
|
HANDLE_FLAG_OVERLAPPED);
|
||||||
serial->in = handle_input_new(serport, serial_gotdata, serial,
|
serial->in = handle_input_new(serport, serial_gotdata, serial,
|
||||||
HANDLE_FLAG_OVERLAPPED |
|
HANDLE_FLAG_OVERLAPPED |
|
||||||
HANDLE_FLAG_IGNOREEOF);
|
HANDLE_FLAG_IGNOREEOF |
|
||||||
|
HANDLE_FLAG_UNITBUFFER);
|
||||||
|
|
||||||
*realhost = dupstr(cfg->serline);
|
*realhost = dupstr(cfg->serline);
|
||||||
|
|
||||||
|
@ -410,6 +410,7 @@ void init_ucs(Config *, struct unicode_data *);
|
|||||||
*/
|
*/
|
||||||
#define HANDLE_FLAG_OVERLAPPED 1
|
#define HANDLE_FLAG_OVERLAPPED 1
|
||||||
#define HANDLE_FLAG_IGNOREEOF 2
|
#define HANDLE_FLAG_IGNOREEOF 2
|
||||||
|
#define HANDLE_FLAG_UNITBUFFER 3
|
||||||
struct handle;
|
struct handle;
|
||||||
typedef int (*handle_inputfn_t)(struct handle *h, void *data, int len);
|
typedef int (*handle_inputfn_t)(struct handle *h, void *data, int len);
|
||||||
typedef void (*handle_outputfn_t)(struct handle *h, int new_backlog);
|
typedef void (*handle_outputfn_t)(struct handle *h, int new_backlog);
|
||||||
|
Loading…
Reference in New Issue
Block a user