mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-05 05:22:47 -05:00
New piece of Windows infrastructure: winhandl.c takes Plink's
thread-based approach to stdin and stdout, wraps it in a halfway sensible API, and makes it a globally available service across all network tools. There is no direct functionality enhancement from this checkin: winplink.c now talks to the new API instead of doing it all internally, but does nothing different as a result. However, this should lay the groundwork for several diverse pieces of work in future: pipe-based ProxyCommand on Windows, a serial port back end, and (hopefully) a pipe-based means of communicating with Pageant, which should have sensible blocking behaviour and hence permit asynchronous agent requests and decrypt-on-demand. [originally from svn r6797]
This commit is contained in:
@ -463,9 +463,9 @@ extern int select_result(WPARAM, LPARAM);
|
||||
|
||||
int do_eventsel_loop(HANDLE other_event)
|
||||
{
|
||||
int n;
|
||||
int n, nhandles, nallhandles;
|
||||
long next, ticks;
|
||||
HANDLE handles[2];
|
||||
HANDLE *handles;
|
||||
SOCKET *sklist;
|
||||
int skcount;
|
||||
long now = GETTICKCOUNT();
|
||||
@ -474,8 +474,13 @@ int do_eventsel_loop(HANDLE other_event)
|
||||
return -1; /* doom */
|
||||
}
|
||||
|
||||
handles[0] = netevent;
|
||||
handles[1] = other_event;
|
||||
handles = handle_get_events(&nhandles);
|
||||
handles = sresize(handles, nhandles+2, HANDLE);
|
||||
nallhandles = nhandles;
|
||||
|
||||
handles[nallhandles++] = netevent;
|
||||
if (other_event)
|
||||
handles[nallhandles++] = other_event;
|
||||
|
||||
if (run_timers(now, &next)) {
|
||||
ticks = next - GETTICKCOUNT();
|
||||
@ -484,10 +489,12 @@ int do_eventsel_loop(HANDLE other_event)
|
||||
ticks = INFINITE;
|
||||
}
|
||||
|
||||
n = MsgWaitForMultipleObjects(other_event ? 2 : 1, handles, FALSE, ticks,
|
||||
n = MsgWaitForMultipleObjects(nallhandles, handles, FALSE, ticks,
|
||||
QS_POSTMESSAGE);
|
||||
|
||||
if (n == WAIT_OBJECT_0 + 0) {
|
||||
if ((unsigned)(n - WAIT_OBJECT_0) < (unsigned)nhandles) {
|
||||
handle_got_event(handles[n - WAIT_OBJECT_0]);
|
||||
} else if (n == WAIT_OBJECT_0 + nhandles) {
|
||||
WSANETWORKEVENTS things;
|
||||
SOCKET socket;
|
||||
extern SOCKET first_socket(int *), next_socket(int *);
|
||||
@ -549,13 +556,15 @@ int do_eventsel_loop(HANDLE other_event)
|
||||
sfree(sklist);
|
||||
}
|
||||
|
||||
sfree(handles);
|
||||
|
||||
if (n == WAIT_TIMEOUT) {
|
||||
now = next;
|
||||
} else {
|
||||
now = GETTICKCOUNT();
|
||||
}
|
||||
|
||||
if (other_event && n == WAIT_OBJECT_0 + 1)
|
||||
if (other_event && n == WAIT_OBJECT_0 + nhandles + 1)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user