diff --git a/src/share/transport/socket/socketTransport.c b/src/share/transport/socket/socketTransport.c index e3a50d93ecd8be453e23b58bcf08acb51fe2e283..666ce2d6d6bedce83741c7f5da3a0c5137185656 100644 --- a/src/share/transport/socket/socketTransport.c +++ b/src/share/transport/socket/socketTransport.c @@ -304,7 +304,7 @@ socketTransport_startListening(jdwpTransportEnv* env, const char* address, { char buf[20]; - int len = sizeof(sa); + socklen_t len = sizeof(sa); jint portNum; err = dbgsysGetSocketName(serverSocketFD, (struct sockaddr *)&sa, &len); @@ -324,7 +324,8 @@ socketTransport_startListening(jdwpTransportEnv* env, const char* address, static jdwpTransportError JNICALL socketTransport_accept(jdwpTransportEnv* env, jlong acceptTimeout, jlong handshakeTimeout) { - int socketLen, err; + socklen_t socketLen; + int err; struct sockaddr_in socket; jlong startTime = (jlong)0; @@ -508,7 +509,7 @@ socketTransport_close(jdwpTransportEnv* env) if (dbgsysSocketClose(fd) < 0) { /* * close failed - it's pointless to restore socketFD here because - * any subsequent close will likely fail aswell. + * any subsequent close will likely fail as well. */ RETURN_IO_ERROR("close failed"); } diff --git a/src/share/transport/socket/sysSocket.h b/src/share/transport/socket/sysSocket.h index b40267ab432fc8d79779a6e75a8252d506ee2861..f80cc67a1de9f83abdbb4f6e1e1bbd205a49fce3 100644 --- a/src/share/transport/socket/sysSocket.h +++ b/src/share/transport/socket/sysSocket.h @@ -34,28 +34,29 @@ #define DBG_EINPROGRESS -150 #define DBG_ETIMEOUT -200 +#ifdef WIN32 +typedef int socklen_t; +#endif int dbgsysSocketClose(int fd); -int dbgsysConnect(int fd, struct sockaddr *him, int len); -int dbgsysFinishConnect(int fd, long timeout); -int dbgsysAccept(int fd, struct sockaddr *him, int *len); -int dbgsysSendTo(int fd, char *buf, int len, int flags, struct sockaddr *to, - int tolen); -int dbgsysRecvFrom(int fd, char *buf, int nbytes, int flags, - struct sockaddr *from, int *fromlen); +int dbgsysConnect(int fd, struct sockaddr *him, socklen_t len); +int dbgsysFinishConnect(int fd, int timeout); +int dbgsysAccept(int fd, struct sockaddr *him, socklen_t *len); +int dbgsysSendTo(int fd, char *buf, size_t len, int flags, struct sockaddr *to, socklen_t tolen); +int dbgsysRecvFrom(int fd, char *buf, size_t nBytes, int flags, struct sockaddr *from, socklen_t *fromlen); int dbgsysListen(int fd, int backlog); -int dbgsysRecv(int fd, char *buf, int nBytes, int flags); -int dbgsysSend(int fd, char *buf, int nBytes, int flags); +int dbgsysRecv(int fd, char *buf, size_t nBytes, int flags); +int dbgsysSend(int fd, char *buf, size_t nBytes, int flags); struct hostent *dbgsysGetHostByName(char *hostname); int dbgsysSocket(int domain, int type, int protocol); -int dbgsysBind(int fd, struct sockaddr *name, int namelen); +int dbgsysBind(int fd, struct sockaddr *name, socklen_t namelen); int dbgsysSetSocketOption(int fd, jint cmd, jboolean on, jvalue value); uint32_t dbgsysInetAddr(const char* cp); uint32_t dbgsysHostToNetworkLong(uint32_t hostlong); unsigned short dbgsysHostToNetworkShort(unsigned short hostshort); uint32_t dbgsysNetworkToHostLong(uint32_t netlong); unsigned short dbgsysNetworkToHostShort(unsigned short netshort); -int dbgsysGetSocketName(int fd, struct sockaddr *him, int *len); +int dbgsysGetSocketName(int fd, struct sockaddr *him, socklen_t *len); int dbgsysConfigureBlocking(int fd, jboolean blocking); int dbgsysPoll(int fd, jboolean rd, jboolean wr, long timeout); int dbgsysGetLastIOError(char *buf, jint size); diff --git a/src/solaris/transport/socket/socket_md.c b/src/solaris/transport/socket/socket_md.c index 74e8d846c7b6614f5119a86dc0a1a3b0d9503a5c..715b7ac066a3add15d5914d7c5c4f299fe39c1df 100644 --- a/src/solaris/transport/socket/socket_md.c +++ b/src/solaris/transport/socket/socket_md.c @@ -49,7 +49,7 @@ dbgsysListen(int fd, int backlog) { } int -dbgsysConnect(int fd, struct sockaddr *name, int namelen) { +dbgsysConnect(int fd, struct sockaddr *name, socklen_t namelen) { int rv = connect(fd, name, namelen); if (rv < 0 && (errno == EINPROGRESS || errno == EINTR)) { return DBG_EINPROGRESS; @@ -59,7 +59,7 @@ dbgsysConnect(int fd, struct sockaddr *name, int namelen) { } int -dbgsysFinishConnect(int fd, long timeout) { +dbgsysFinishConnect(int fd, int timeout) { int rv = dbgsysPoll(fd, 0, 1, timeout); if (rv == 0) { return DBG_ETIMEOUT; @@ -71,7 +71,7 @@ dbgsysFinishConnect(int fd, long timeout) { } int -dbgsysAccept(int fd, struct sockaddr *name, int *namelen) { +dbgsysAccept(int fd, struct sockaddr *name, socklen_t *namelen) { int rv; for (;;) { rv = accept(fd, name, namelen); @@ -85,8 +85,8 @@ dbgsysAccept(int fd, struct sockaddr *name, int *namelen) { } int -dbgsysRecvFrom(int fd, char *buf, int nBytes, - int flags, struct sockaddr *from, int *fromlen) { +dbgsysRecvFrom(int fd, char *buf, size_t nBytes, + int flags, struct sockaddr *from, socklen_t *fromlen) { int rv; do { rv = recvfrom(fd, buf, nBytes, flags, from, fromlen); @@ -96,8 +96,8 @@ dbgsysRecvFrom(int fd, char *buf, int nBytes, } int -dbgsysSendTo(int fd, char *buf, int len, - int flags, struct sockaddr *to, int tolen) { +dbgsysSendTo(int fd, char *buf, size_t len, + int flags, struct sockaddr *to, socklen_t tolen) { int rv; do { rv = sendto(fd, buf, len, flags, to, tolen); @@ -107,7 +107,7 @@ dbgsysSendTo(int fd, char *buf, int len, } int -dbgsysRecv(int fd, char *buf, int nBytes, int flags) { +dbgsysRecv(int fd, char *buf, size_t nBytes, int flags) { int rv; do { rv = recv(fd, buf, nBytes, flags); @@ -117,7 +117,7 @@ dbgsysRecv(int fd, char *buf, int nBytes, int flags) { } int -dbgsysSend(int fd, char *buf, int nBytes, int flags) { +dbgsysSend(int fd, char *buf, size_t nBytes, int flags) { int rv; do { rv = send(fd, buf, nBytes, flags); @@ -151,7 +151,7 @@ int dbgsysSocketClose(int fd) { } int -dbgsysBind(int fd, struct sockaddr *name, int namelen) { +dbgsysBind(int fd, struct sockaddr *name, socklen_t namelen) { return bind(fd, name, namelen); } @@ -171,7 +171,7 @@ dbgsysNetworkToHostShort(unsigned short netshort) { } int -dbgsysGetSocketName(int fd, struct sockaddr *name, int *namelen) { +dbgsysGetSocketName(int fd, struct sockaddr *name, socklen_t *namelen) { return getsockname(fd, name, namelen); } diff --git a/src/windows/transport/socket/socket_md.c b/src/windows/transport/socket/socket_md.c index 5b025cf2f4eae0b6cc3f28849ec10373c145e6b2..8ac98c96aaedc2a255f675b5acfa03f9cb13b9d7 100644 --- a/src/windows/transport/socket/socket_md.c +++ b/src/windows/transport/socket/socket_md.c @@ -125,7 +125,7 @@ dbgsysListen(int fd, int backlog) { } int -dbgsysConnect(int fd, struct sockaddr *name, int namelen) { +dbgsysConnect(int fd, struct sockaddr *name, socklen_t namelen) { int rv = connect(fd, name, namelen); if (rv == SOCKET_ERROR) { if (WSAGetLastError() == WSAEINPROGRESS || WSAGetLastError() == WSAEWOULDBLOCK) { @@ -135,7 +135,7 @@ dbgsysConnect(int fd, struct sockaddr *name, int namelen) { return rv; } -int dbgsysFinishConnect(int fd, long timeout) { +int dbgsysFinishConnect(int fd, int timeout) { int rv; struct timeval t; fd_set wr, ex; @@ -171,30 +171,30 @@ int dbgsysFinishConnect(int fd, long timeout) { int -dbgsysAccept(int fd, struct sockaddr *name, int *namelen) { +dbgsysAccept(int fd, struct sockaddr *name, socklen_t *namelen) { return (int)accept(fd, name, namelen); } int -dbgsysRecvFrom(int fd, char *buf, int nBytes, - int flags, struct sockaddr *from, int *fromlen) { - return recvfrom(fd, buf, nBytes, flags, from, fromlen); +dbgsysRecvFrom(int fd, char *buf, size_t nBytes, + int flags, struct sockaddr *from, socklen_t *fromlen) { + return recvfrom(fd, buf, (int)nBytes, flags, from, fromlen); } int -dbgsysSendTo(int fd, char *buf, int len, - int flags, struct sockaddr *to, int tolen) { - return sendto(fd, buf, len, flags, to, tolen); +dbgsysSendTo(int fd, char *buf, size_t len, + int flags, struct sockaddr *to, socklen_t tolen) { + return sendto(fd, buf, (int)len, flags, to, tolen); } int -dbgsysRecv(int fd, char *buf, int nBytes, int flags) { - return recv(fd, buf, nBytes, flags); +dbgsysRecv(int fd, char *buf, size_t nBytes, int flags) { + return recv(fd, buf, (int) nBytes, flags); } int -dbgsysSend(int fd, char *buf, int nBytes, int flags) { - return send(fd, buf, nBytes, flags); +dbgsysSend(int fd, char *buf, size_t nBytes, int flags) { + return send(fd, buf, (int)nBytes, flags); } struct hostent * @@ -232,7 +232,7 @@ dbgsysSocketClose(int fd) { /* Additions to original follow */ int -dbgsysBind(int fd, struct sockaddr *name, int namelen) { +dbgsysBind(int fd, struct sockaddr *name, socklen_t namelen) { return bind(fd, name, namelen); } @@ -253,7 +253,7 @@ dbgsysNetworkToHostShort(unsigned short netshort) { } int -dbgsysGetSocketName(int fd, struct sockaddr *name, int *namelen) { +dbgsysGetSocketName(int fd, struct sockaddr *name, socklen_t *namelen) { return getsockname(fd, name, namelen); } @@ -426,7 +426,7 @@ dbgsysTlsGet(int index) { } #define FT2INT64(ft) \ - ((long)(ft).dwHighDateTime << 32 | (long)(ft).dwLowDateTime) + ((INT64)(ft).dwHighDateTime << 32 | (INT64)(ft).dwLowDateTime) long dbgsysCurrentTimeMillis() {