src/solaris/native/java/net/Inet6AddressImpl.c

Print this page

        

*** 504,514 **** --- 504,526 ---- gettimeofday(&tv, NULL); memcpy(sendbuf + sizeof(struct icmp6_hdr), &tv, sizeof(tv)); plen = sizeof(struct icmp6_hdr) + sizeof(tv); n = sendto(fd, sendbuf, plen, 0, (struct sockaddr*) him, sizeof(struct sockaddr_in6)); if (n < 0 && errno != EINPROGRESS) { + #ifdef __linux__ + if (errno == EINVAL) { + /* + * On some Linuxes, when bound to the loopback interface, sendto + * will fail and errno will be set to EINVAL. When that happens, + * don't throw an exception, just return false. + */ + close(fd); + return JNI_FALSE; + } + #endif /*__linux__ */ NET_ThrowNew(env, errno, "Can't send ICMP packet"); + close(fd); return JNI_FALSE; } tmout2 = timeout > 1000 ? 1000 : timeout; do {