Skip to content

Commit

Permalink
ipc-win32: add trace2 debugging
Browse files Browse the repository at this point in the history
Create "ipc-debug" category events to log unexpected errors
when creating Simple-IPC connections.

Signed-off-by: Jeff Hostetler <[email protected]>
  • Loading branch information
jeffhostetler authored and dscho committed Aug 16, 2021
1 parent 751d7c3 commit ddab099
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions compat/simple-ipc/ipc-win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ static enum ipc_active_state get_active_state(wchar_t *pipe_path)
if (GetLastError() == ERROR_FILE_NOT_FOUND)
return IPC_STATE__PATH_NOT_FOUND;

trace2_data_intmax("ipc-debug", NULL, "getstate/waitpipe/gle",
(intmax_t)GetLastError());

return IPC_STATE__OTHER_ERROR;
}

Expand Down Expand Up @@ -112,6 +115,11 @@ static enum ipc_active_state connect_to_server(
if (GetLastError() == ERROR_SEM_TIMEOUT)
return IPC_STATE__NOT_LISTENING;

gle = GetLastError();
trace2_data_intmax("ipc-debug", NULL,
"connect/waitpipe/gle",
(intmax_t)gle);

return IPC_STATE__OTHER_ERROR;
}

Expand All @@ -133,17 +141,31 @@ static enum ipc_active_state connect_to_server(
break; /* try again */

default:
trace2_data_intmax("ipc-debug", NULL,
"connect/createfile/gle",
(intmax_t)gle);

return IPC_STATE__OTHER_ERROR;
}
}

if (!SetNamedPipeHandleState(hPipe, &mode, NULL, NULL)) {
gle = GetLastError();
trace2_data_intmax("ipc-debug", NULL,
"connect/setpipestate/gle",
(intmax_t)gle);

CloseHandle(hPipe);
return IPC_STATE__OTHER_ERROR;
}

*pfd = _open_osfhandle((intptr_t)hPipe, O_RDWR|O_BINARY);
if (*pfd < 0) {
gle = GetLastError();
trace2_data_intmax("ipc-debug", NULL,
"connect/openosfhandle/gle",
(intmax_t)gle);

CloseHandle(hPipe);
return IPC_STATE__OTHER_ERROR;
}
Expand Down

0 comments on commit ddab099

Please sign in to comment.