Skip to content

Commit 9bd51d4

Browse files
jeffhostetlergitster
authored andcommitted
simple-ipc/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]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 59c9232 commit 9bd51d4

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

compat/simple-ipc/ipc-win32.c

Lines changed: 24 additions & 1 deletion
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

@@ -109,9 +112,15 @@ static enum ipc_active_state connect_to_server(
109112
t_start_ms = (DWORD)(getnanotime() / 1000000);
110113

111114
if (!WaitNamedPipeW(wpath, timeout_ms)) {
112-
if (GetLastError() == ERROR_SEM_TIMEOUT)
115+
DWORD gleWait = GetLastError();
116+
117+
if (gleWait == ERROR_SEM_TIMEOUT)
113118
return IPC_STATE__NOT_LISTENING;
114119

120+
trace2_data_intmax("ipc-debug", NULL,
121+
"connect/waitpipe/gle",
122+
(intmax_t)gleWait);
123+
115124
return IPC_STATE__OTHER_ERROR;
116125
}
117126

@@ -133,17 +142,31 @@ static enum ipc_active_state connect_to_server(
133142
break; /* try again */
134143

135144
default:
145+
trace2_data_intmax("ipc-debug", NULL,
146+
"connect/createfile/gle",
147+
(intmax_t)gle);
148+
136149
return IPC_STATE__OTHER_ERROR;
137150
}
138151
}
139152

140153
if (!SetNamedPipeHandleState(hPipe, &mode, NULL, NULL)) {
154+
gle = GetLastError();
155+
trace2_data_intmax("ipc-debug", NULL,
156+
"connect/setpipestate/gle",
157+
(intmax_t)gle);
158+
141159
CloseHandle(hPipe);
142160
return IPC_STATE__OTHER_ERROR;
143161
}
144162

145163
*pfd = _open_osfhandle((intptr_t)hPipe, O_RDWR|O_BINARY);
146164
if (*pfd < 0) {
165+
gle = GetLastError();
166+
trace2_data_intmax("ipc-debug", NULL,
167+
"connect/openosfhandle/gle",
168+
(intmax_t)gle);
169+
147170
CloseHandle(hPipe);
148171
return IPC_STATE__OTHER_ERROR;
149172
}

0 commit comments

Comments
 (0)