8227124: "could not open pipe" error does not report error details
Reviewed-by: sspitsyn, cjplummer
--- a/src/hotspot/os/windows/attachListener_windows.cpp Fri Jul 05 13:40:29 2019 +0200
+++ b/src/hotspot/os/windows/attachListener_windows.cpp Fri Jul 05 10:35:37 2019 -0700
@@ -272,23 +272,13 @@
// open the pipe to the client
HANDLE Win32AttachOperation::open_pipe() {
- HANDLE hPipe;
-
- hPipe = ::CreateFile( pipe(), // pipe name
+ HANDLE hPipe = ::CreateFile( pipe(), // pipe name
GENERIC_WRITE, // write only
0, // no sharing
NULL, // default security attributes
OPEN_EXISTING, // opens existing pipe
0, // default attributes
NULL); // no template file
-
- if (hPipe != INVALID_HANDLE_VALUE) {
- // shouldn't happen as there is a pipe created per operation
- if (::GetLastError() == ERROR_PIPE_BUSY) {
- ::CloseHandle(hPipe);
- return INVALID_HANDLE_VALUE;
- }
- }
return hPipe;
}
@@ -307,8 +297,7 @@
}
buf += nwrote;
len -= nwrote;
- }
- while (len > 0);
+ } while (len > 0);
return TRUE;
}
@@ -326,6 +315,7 @@
// java_suspend_self() via check_and_wait_while_suspended()
HANDLE hPipe = open_pipe();
+ int lastError = (int)::GetLastError();
if (hPipe != INVALID_HANDLE_VALUE) {
BOOL fSuccess;
@@ -337,6 +327,7 @@
if (fSuccess) {
fSuccess = write_pipe(hPipe, (char*)result_stream->base(), (int)(result_stream->size()));
}
+ lastError = (int)::GetLastError();
// Need to flush buffers
FlushFileBuffers(hPipe);
@@ -345,10 +336,10 @@
if (fSuccess) {
log_debug(attach)("wrote result of attach operation %s to pipe %s", name(), pipe());
} else {
- log_error(attach)("failure writing result of operation %s to pipe %s", name(), pipe());
+ log_error(attach)("failure (%d) writing result of operation %s to pipe %s", lastError, name(), pipe());
}
} else {
- log_error(attach)("could not open pipe %s to send result of operation %s", pipe(), name());
+ log_error(attach)("could not open (%d) pipe %s to send result of operation %s", lastError, pipe(), name());
}
DWORD res = ::WaitForSingleObject(Win32AttachListener::mutex(), INFINITE);