mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-23 14:04:59 +02:00
4-12 C1
This commit is contained in:
parent
d3640ddd8e
commit
8fb27e8fc6
@ -77,12 +77,13 @@ void agent_sm_process_action_queue() {
|
||||
0, // client time-out
|
||||
NULL);
|
||||
|
||||
/* remove action from queue before the assigining iocp port*/
|
||||
/* remove action from queue before assigning iocp port*/
|
||||
con->next = list;
|
||||
list = con;
|
||||
actions_remaining = InterlockedAnd(&action_queue, ~ACTION_LISTEN);
|
||||
CreateIoCompletionPort(h, ioc_port, con, 0);
|
||||
|
||||
con->next = list;
|
||||
list = con;
|
||||
|
||||
}
|
||||
else {
|
||||
/* cleanup up a done connection*/
|
||||
@ -131,48 +132,33 @@ void agent_sm_raise(enum agent_sm_event event) {
|
||||
|
||||
}
|
||||
|
||||
HANDLE iocp_workers[4];
|
||||
|
||||
DWORD WINAPI iocp_work(LPVOID lpParam) {
|
||||
DWORD bytes;
|
||||
struct agent_connection* con;
|
||||
OVERLAPPED *p_ol;
|
||||
while (1) {
|
||||
GetQueuedCompletionStatus(ioc_port, &bytes, &con, &p_ol, INFINITE);
|
||||
agent_connection_on_io(con, bytes, p_ol);
|
||||
}
|
||||
}
|
||||
|
||||
int agent_start() {
|
||||
int i;
|
||||
action_queue = 0;
|
||||
list = NULL;
|
||||
ioc_port = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, NULL, 0);
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
iocp_workers[i] = CreateThread(NULL, 0, iocp_work, NULL, 0, NULL);
|
||||
|
||||
action_queue = ACTION_LISTEN;
|
||||
agent_sm_process_action_queue();
|
||||
}
|
||||
|
||||
void agent_listen();
|
||||
void agent_shutdown();
|
||||
void agent_cleanup_connection(struct agent_connection*);
|
||||
|
||||
int agent_listen() {
|
||||
|
||||
ioc_port = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, NULL, 0);
|
||||
|
||||
|
||||
BOOL ret;
|
||||
HANDLE temp;
|
||||
DWORD err, bytes;
|
||||
ULONG_PTR ptr;
|
||||
HANDLE h = CreateNamedPipe(
|
||||
pipe_name, // pipe name
|
||||
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, // read/write access
|
||||
PIPE_TYPE_MESSAGE | // message type pipe
|
||||
PIPE_READMODE_MESSAGE | // message-read mode
|
||||
PIPE_WAIT, // blocking mode
|
||||
PIPE_UNLIMITED_INSTANCES, // max. instances
|
||||
BUFSIZE, // output buffer size
|
||||
BUFSIZE, // input buffer size
|
||||
0, // client time-out
|
||||
NULL);
|
||||
|
||||
temp = CreateIoCompletionPort(h, ioc_port, NULL, 0);
|
||||
|
||||
OVERLAPPED ol, *pol;
|
||||
ZeroMemory(&ol, sizeof(ol));
|
||||
ret = ConnectNamedPipe(h, &ol);
|
||||
err = GetLastError();
|
||||
|
||||
GetQueuedCompletionStatus(ioc_port, &bytes, &ptr, &pol, INFINITE);
|
||||
|
||||
//Sleep(INFINITE);
|
||||
return 1;
|
||||
void agent_shutdown() {
|
||||
agent_sm_raise(SHUTDOWN);
|
||||
while (list != NULL)
|
||||
Sleep(100);
|
||||
}
|
||||
|
@ -3,10 +3,7 @@
|
||||
|
||||
|
||||
int agent_start();
|
||||
|
||||
void agent_listen();
|
||||
void agent_shutdown();
|
||||
void agent_cleanup_connection(struct agent_connection*);
|
||||
|
||||
struct agent_connection {
|
||||
enum {
|
||||
@ -19,5 +16,5 @@ struct agent_connection {
|
||||
struct agent_con* next;
|
||||
};
|
||||
|
||||
void agent_connection_on_io(struct agent_connection*);
|
||||
void agent_connection_on_io(struct agent_connection*, DWORD, OVERLAPPED*);
|
||||
void agent_connection_disconnect(struct agent_connection*);
|
@ -31,25 +31,20 @@
|
||||
#include "agent.h"
|
||||
#define BUFSIZE 5 * 1024
|
||||
|
||||
static HANDLE ioc_port;
|
||||
|
||||
|
||||
|
||||
ssh_agent_connection::ssh_agent_connection(HANDLE h) {
|
||||
connection = h;
|
||||
state = LISTENING;
|
||||
void agent_connection_on_io(struct agent_connection* con, DWORD bytes, OVERLAPPED* ol) {
|
||||
switch (con->state) {
|
||||
case LISTENING:
|
||||
break;
|
||||
case READING:
|
||||
break;
|
||||
case WRITING:
|
||||
break;
|
||||
default:
|
||||
DebugBreak();
|
||||
}
|
||||
}
|
||||
|
||||
ssh_agent_connection::~ssh_agent_connection() {
|
||||
CloseHandle(connection);
|
||||
void agent_connection_disconnect(struct agent_connection* con) {
|
||||
CancelIoEx(con->connection, NULL);
|
||||
DisconnectNamedPipe(con->connection);
|
||||
}
|
||||
|
||||
void ssh_agent_connection::process_iocp(DWORD bytes_transferred, OVERLAPPED* pol) {
|
||||
|
||||
}
|
||||
|
||||
void ssh_agent_connection::disconnect() {
|
||||
DisconnectNamedPipe(connection);
|
||||
CancelIoEx(connection, NULL);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user