Skip to content

Commit 8956648

Browse files
committed
ipc-win32: add trace2 debugging
Create "ipc-debug" category events to log unexpected errors when creating Simple-IPC connections. Signed-off-by: Jeff Hostetler <[email protected]>
1 parent e024c75 commit 8956648

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

compat/simple-ipc/ipc-win32.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ static enum ipc_active_state get_active_state(wchar_t *pipe_path)
4949
if (GetLastError() == ERROR_FILE_NOT_FOUND)
5050
return IPC_STATE__PATH_NOT_FOUND;
5151

52+
trace2_data_intmax("ipc-debug", NULL, "getstate/waitpipe/gle",
53+
(intmax_t)GetLastError());
54+
5255
return IPC_STATE__OTHER_ERROR;
5356
}
5457

@@ -112,6 +115,11 @@ static enum ipc_active_state connect_to_server(
112115
if (GetLastError() == ERROR_SEM_TIMEOUT)
113116
return IPC_STATE__NOT_LISTENING;
114117

118+
gle = GetLastError();
119+
trace2_data_intmax("ipc-debug", NULL,
120+
"connect/waitpipe/gle",
121+
(intmax_t)gle);
122+
115123
return IPC_STATE__OTHER_ERROR;
116124
}
117125

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

135143
default:
144+
trace2_data_intmax("ipc-debug", NULL,
145+
"connect/createfile/gle",
146+
(intmax_t)gle);
147+
136148
return IPC_STATE__OTHER_ERROR;
137149
}
138150
}
139151

140152
if (!SetNamedPipeHandleState(hPipe, &mode, NULL, NULL)) {
153+
gle = GetLastError();
154+
trace2_data_intmax("ipc-debug", NULL,
155+
"connect/setpipestate/gle",
156+
(intmax_t)gle);
157+
141158
CloseHandle(hPipe);
142159
return IPC_STATE__OTHER_ERROR;
143160
}
144161

145162
*pfd = _open_osfhandle((intptr_t)hPipe, O_RDWR|O_BINARY);
146163
if (*pfd < 0) {
164+
gle = GetLastError();
165+
trace2_data_intmax("ipc-debug", NULL,
166+
"connect/openosfhandle/gle",
167+
(intmax_t)gle);
168+
147169
CloseHandle(hPipe);
148170
return IPC_STATE__OTHER_ERROR;
149171
}

0 commit comments

Comments
 (0)