mirror of
https://github.com/PowerShell/Win32-OpenSSH.git
synced 2025-07-24 22:45:17 +02:00
Handling errors on GetQueuedCompletionStatus()
This commit is contained in:
parent
87dee940d1
commit
8f247d5c00
@ -90,7 +90,7 @@ BOOL WINAPI ctrl_c_handler(
|
|||||||
int main() {
|
int main() {
|
||||||
if (!StartServiceCtrlDispatcher(diapatch_table)) {
|
if (!StartServiceCtrlDispatcher(diapatch_table)) {
|
||||||
if (GetLastError() == ERROR_FAILED_SERVICE_CONTROLLER_CONNECT) {
|
if (GetLastError() == ERROR_FAILED_SERVICE_CONTROLLER_CONNECT) {
|
||||||
//console app
|
/* console app */
|
||||||
SetConsoleCtrlHandler(ctrl_c_handler, TRUE);
|
SetConsoleCtrlHandler(ctrl_c_handler, TRUE);
|
||||||
return agent_start();
|
return agent_start();
|
||||||
}
|
}
|
||||||
|
@ -93,6 +93,7 @@ void agent_sm_process_action_queue() {
|
|||||||
else
|
else
|
||||||
prev->next = tmp->next;
|
prev->next = tmp->next;
|
||||||
CloseHandle(tmp->connection);
|
CloseHandle(tmp->connection);
|
||||||
|
printf("deleting %p\n", tmp);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -130,11 +131,19 @@ HANDLE iocp_workers[4];
|
|||||||
|
|
||||||
DWORD WINAPI iocp_work(LPVOID lpParam) {
|
DWORD WINAPI iocp_work(LPVOID lpParam) {
|
||||||
DWORD bytes;
|
DWORD bytes;
|
||||||
struct agent_connection* con;
|
struct agent_connection* con = NULL;
|
||||||
OVERLAPPED *p_ol;
|
OVERLAPPED *p_ol;
|
||||||
while (1) {
|
while (1) {
|
||||||
if (GetQueuedCompletionStatus(ioc_port, &bytes, &(ULONG_PTR)con, &p_ol, INFINITE) == FALSE)
|
con = NULL;
|
||||||
return 0;
|
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);
|
agent_connection_on_io(con, bytes, p_ol);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ struct agent_connection {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void agent_connection_on_io(struct agent_connection*, DWORD, OVERLAPPED*);
|
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*);
|
void agent_connection_disconnect(struct agent_connection*);
|
||||||
|
|
||||||
int agent_start();
|
int agent_start();
|
||||||
|
@ -30,6 +30,11 @@
|
|||||||
*/
|
*/
|
||||||
#include "agent.h"
|
#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) {
|
void agent_connection_on_io(struct agent_connection* con, DWORD bytes, OVERLAPPED* ol) {
|
||||||
|
|
||||||
/* process error */
|
/* process error */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user