6432567: PIT : com/sun/jdi/BadHandshakeTest.java fails due to java.net.ConnectException
Reviewed-by: tbell, ohair, dcubed, andrew
This commit is contained in:
parent
5d15a44868
commit
d1f3f3509d
@ -134,15 +134,16 @@ setOptions(int fd)
|
|||||||
|
|
||||||
static jdwpTransportError
|
static jdwpTransportError
|
||||||
handshake(int fd, jlong timeout) {
|
handshake(int fd, jlong timeout) {
|
||||||
char *hello = "JDWP-Handshake";
|
const char *hello = "JDWP-Handshake";
|
||||||
char b[16];
|
char b[16];
|
||||||
int rv, received, i;
|
int rv, helloLen, received;
|
||||||
|
|
||||||
if (timeout > 0) {
|
if (timeout > 0) {
|
||||||
dbgsysConfigureBlocking(fd, JNI_FALSE);
|
dbgsysConfigureBlocking(fd, JNI_FALSE);
|
||||||
}
|
}
|
||||||
|
helloLen = (int)strlen(hello);
|
||||||
received = 0;
|
received = 0;
|
||||||
while (received < (int)strlen(hello)) {
|
while (received < helloLen) {
|
||||||
int n;
|
int n;
|
||||||
char *buf;
|
char *buf;
|
||||||
if (timeout > 0) {
|
if (timeout > 0) {
|
||||||
@ -154,7 +155,7 @@ handshake(int fd, jlong timeout) {
|
|||||||
}
|
}
|
||||||
buf = b;
|
buf = b;
|
||||||
buf += received;
|
buf += received;
|
||||||
n = dbgsysRecv(fd, buf, (int)strlen(hello)-received, 0);
|
n = dbgsysRecv(fd, buf, helloLen-received, 0);
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
setLastError(0, "handshake failed - connection prematurally closed");
|
setLastError(0, "handshake failed - connection prematurally closed");
|
||||||
return JDWPTRANSPORT_ERROR_IO_ERROR;
|
return JDWPTRANSPORT_ERROR_IO_ERROR;
|
||||||
@ -167,20 +168,19 @@ handshake(int fd, jlong timeout) {
|
|||||||
if (timeout > 0) {
|
if (timeout > 0) {
|
||||||
dbgsysConfigureBlocking(fd, JNI_TRUE);
|
dbgsysConfigureBlocking(fd, JNI_TRUE);
|
||||||
}
|
}
|
||||||
for (i=0; i<(int)strlen(hello); i++) {
|
if (strncmp(b, hello, received) != 0) {
|
||||||
if (b[i] != hello[i]) {
|
char msg[80+2*16];
|
||||||
char msg[64];
|
b[received] = '\0';
|
||||||
strcpy(msg, "handshake failed - received >");
|
/*
|
||||||
strncat(msg, b, strlen(hello));
|
* We should really use snprintf here but it's not available on Windows.
|
||||||
strcat(msg, "< - excepted >");
|
* We can't use jio_snprintf without linking the transport against the VM.
|
||||||
strcat(msg, hello);
|
*/
|
||||||
strcat(msg, "<");
|
sprintf(msg, "handshake failed - received >%s< - expected >%s<", b, hello);
|
||||||
setLastError(0, msg);
|
setLastError(0, msg);
|
||||||
return JDWPTRANSPORT_ERROR_IO_ERROR;
|
return JDWPTRANSPORT_ERROR_IO_ERROR;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dbgsysSend(fd, hello, (int)strlen(hello), 0) != (int)strlen(hello)) {
|
if (dbgsysSend(fd, (char*)hello, helloLen, 0) != helloLen) {
|
||||||
RETURN_IO_ERROR("send failed during handshake");
|
RETURN_IO_ERROR("send failed during handshake");
|
||||||
}
|
}
|
||||||
return JDWPTRANSPORT_ERROR_NONE;
|
return JDWPTRANSPORT_ERROR_NONE;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* @test
|
/* @test
|
||||||
* @bug 6306165
|
* @bug 6306165 6432567
|
||||||
* @summary Check that a bad handshake doesn't cause a debuggee to abort
|
* @summary Check that a bad handshake doesn't cause a debuggee to abort
|
||||||
*
|
*
|
||||||
* @build VMConnection BadHandshakeTest Exit0
|
* @build VMConnection BadHandshakeTest Exit0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user