mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-23 22:15:37 +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
|
0, // client time-out
|
||||||
NULL);
|
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);
|
actions_remaining = InterlockedAnd(&action_queue, ~ACTION_LISTEN);
|
||||||
CreateIoCompletionPort(h, ioc_port, con, 0);
|
CreateIoCompletionPort(h, ioc_port, con, 0);
|
||||||
|
|
||||||
con->next = list;
|
|
||||||
list = con;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* cleanup up a done connection*/
|
/* 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 agent_start() {
|
||||||
|
int i;
|
||||||
action_queue = 0;
|
action_queue = 0;
|
||||||
list = NULL;
|
list = NULL;
|
||||||
ioc_port = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, NULL, 0);
|
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;
|
action_queue = ACTION_LISTEN;
|
||||||
agent_sm_process_action_queue();
|
agent_sm_process_action_queue();
|
||||||
}
|
}
|
||||||
|
|
||||||
void agent_listen();
|
void agent_shutdown() {
|
||||||
void agent_shutdown();
|
agent_sm_raise(SHUTDOWN);
|
||||||
void agent_cleanup_connection(struct agent_connection*);
|
while (list != NULL)
|
||||||
|
Sleep(100);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,7 @@
|
|||||||
|
|
||||||
|
|
||||||
int agent_start();
|
int agent_start();
|
||||||
|
|
||||||
void agent_listen();
|
|
||||||
void agent_shutdown();
|
void agent_shutdown();
|
||||||
void agent_cleanup_connection(struct agent_connection*);
|
|
||||||
|
|
||||||
struct agent_connection {
|
struct agent_connection {
|
||||||
enum {
|
enum {
|
||||||
@ -19,5 +16,5 @@ struct agent_connection {
|
|||||||
struct agent_con* next;
|
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*);
|
void agent_connection_disconnect(struct agent_connection*);
|
@ -31,25 +31,20 @@
|
|||||||
#include "agent.h"
|
#include "agent.h"
|
||||||
#define BUFSIZE 5 * 1024
|
#define BUFSIZE 5 * 1024
|
||||||
|
|
||||||
static HANDLE ioc_port;
|
void agent_connection_on_io(struct agent_connection* con, DWORD bytes, OVERLAPPED* ol) {
|
||||||
|
switch (con->state) {
|
||||||
|
case LISTENING:
|
||||||
|
break;
|
||||||
ssh_agent_connection::ssh_agent_connection(HANDLE h) {
|
case READING:
|
||||||
connection = h;
|
break;
|
||||||
state = LISTENING;
|
case WRITING:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
DebugBreak();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ssh_agent_connection::~ssh_agent_connection() {
|
void agent_connection_disconnect(struct agent_connection* con) {
|
||||||
CloseHandle(connection);
|
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