8227124: "could not open pipe" error does not report error details

Reviewed-by: sspitsyn, cjplummer
This commit is contained in:
Alex Menkov 2019-07-05 10:35:37 -07:00
parent 7f1f9a50ae
commit f464df375f

View File

@ -272,23 +272,13 @@ Win32AttachOperation* Win32AttachListener::dequeue() {
// open the pipe to the client // open the pipe to the client
HANDLE Win32AttachOperation::open_pipe() { HANDLE Win32AttachOperation::open_pipe() {
HANDLE hPipe; HANDLE hPipe = ::CreateFile( pipe(), // pipe name
hPipe = ::CreateFile( pipe(), // pipe name
GENERIC_WRITE, // write only GENERIC_WRITE, // write only
0, // no sharing 0, // no sharing
NULL, // default security attributes NULL, // default security attributes
OPEN_EXISTING, // opens existing pipe OPEN_EXISTING, // opens existing pipe
0, // default attributes 0, // default attributes
NULL); // no template file 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; return hPipe;
} }
@ -307,8 +297,7 @@ BOOL Win32AttachOperation::write_pipe(HANDLE hPipe, char* buf, int len) {
} }
buf += nwrote; buf += nwrote;
len -= nwrote; len -= nwrote;
} } while (len > 0);
while (len > 0);
return TRUE; return TRUE;
} }
@ -326,6 +315,7 @@ void Win32AttachOperation::complete(jint result, bufferedStream* result_stream)
// java_suspend_self() via check_and_wait_while_suspended() // java_suspend_self() via check_and_wait_while_suspended()
HANDLE hPipe = open_pipe(); HANDLE hPipe = open_pipe();
int lastError = (int)::GetLastError();
if (hPipe != INVALID_HANDLE_VALUE) { if (hPipe != INVALID_HANDLE_VALUE) {
BOOL fSuccess; BOOL fSuccess;
@ -337,6 +327,7 @@ void Win32AttachOperation::complete(jint result, bufferedStream* result_stream)
if (fSuccess) { if (fSuccess) {
fSuccess = write_pipe(hPipe, (char*)result_stream->base(), (int)(result_stream->size())); fSuccess = write_pipe(hPipe, (char*)result_stream->base(), (int)(result_stream->size()));
} }
lastError = (int)::GetLastError();
// Need to flush buffers // Need to flush buffers
FlushFileBuffers(hPipe); FlushFileBuffers(hPipe);
@ -345,10 +336,10 @@ void Win32AttachOperation::complete(jint result, bufferedStream* result_stream)
if (fSuccess) { if (fSuccess) {
log_debug(attach)("wrote result of attach operation %s to pipe %s", name(), pipe()); log_debug(attach)("wrote result of attach operation %s to pipe %s", name(), pipe());
} else { } 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 { } 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); DWORD res = ::WaitForSingleObject(Win32AttachListener::mutex(), INFINITE);