diff --git a/contrib/win32/win32compat/ssh-agent/agent-main.c b/contrib/win32/win32compat/ssh-agent/agent-main.c index 2295565..61479b7 100644 --- a/contrib/win32/win32compat/ssh-agent/agent-main.c +++ b/contrib/win32/win32compat/ssh-agent/agent-main.c @@ -90,7 +90,7 @@ BOOL WINAPI ctrl_c_handler( int main() { if (!StartServiceCtrlDispatcher(diapatch_table)) { if (GetLastError() == ERROR_FAILED_SERVICE_CONTROLLER_CONNECT) { - //console app + /* console app */ SetConsoleCtrlHandler(ctrl_c_handler, TRUE); return agent_start(); } diff --git a/contrib/win32/win32compat/ssh-agent/agent.c b/contrib/win32/win32compat/ssh-agent/agent.c index da06212..11d964d 100644 --- a/contrib/win32/win32compat/ssh-agent/agent.c +++ b/contrib/win32/win32compat/ssh-agent/agent.c @@ -93,6 +93,7 @@ void agent_sm_process_action_queue() { else prev->next = tmp->next; CloseHandle(tmp->connection); + printf("deleting %p\n", tmp); free(tmp); break; } @@ -130,11 +131,19 @@ HANDLE iocp_workers[4]; DWORD WINAPI iocp_work(LPVOID lpParam) { DWORD bytes; - struct agent_connection* con; + struct agent_connection* con = NULL; OVERLAPPED *p_ol; while (1) { - if (GetQueuedCompletionStatus(ioc_port, &bytes, &(ULONG_PTR)con, &p_ol, INFINITE) == FALSE) - return 0; + con = NULL; + p_ol = NULL; + if (GetQueuedCompletionStatus(ioc_port, &bytes, &(ULONG_PTR)con, &p_ol, INFINITE) == FALSE) { + printf("error: %d on %p \n", GetLastError(), con); + if (con) + agent_connection_on_error(con, GetLastError()); + else + return 0; + } + //printf("io on %p state %d bytes %d\n", con, con->state, bytes); agent_connection_on_io(con, bytes, p_ol); } diff --git a/contrib/win32/win32compat/ssh-agent/agent.h b/contrib/win32/win32compat/ssh-agent/agent.h index 4cbf158..bd40988 100644 --- a/contrib/win32/win32compat/ssh-agent/agent.h +++ b/contrib/win32/win32compat/ssh-agent/agent.h @@ -22,6 +22,7 @@ struct agent_connection { }; void agent_connection_on_io(struct agent_connection*, DWORD, OVERLAPPED*); +void agent_connection_on_error(struct agent_connection* , DWORD ); void agent_connection_disconnect(struct agent_connection*); int agent_start(); diff --git a/contrib/win32/win32compat/ssh-agent/connection.c b/contrib/win32/win32compat/ssh-agent/connection.c index 59abf66..11e1684 100644 --- a/contrib/win32/win32compat/ssh-agent/connection.c +++ b/contrib/win32/win32compat/ssh-agent/connection.c @@ -30,6 +30,11 @@ */ #include "agent.h" +void agent_connection_on_error(struct agent_connection* con, DWORD error) { + con->state = DONE; + agent_cleanup_connection(con); +} + void agent_connection_on_io(struct agent_connection* con, DWORD bytes, OVERLAPPED* ol) { /* process error */