Print this page


Split Close
Expand all
Collapse all
          --- old/src/solaris/native/java/net/Inet6AddressImpl.c
          +++ new/src/solaris/native/java/net/Inet6AddressImpl.c
↓ open down ↓ 498 lines elided ↑ open up ↑
 499  499        /* let's tag the ECHO packet with our pid so we can identify it */
 500  500        icmp6->icmp6_id = htons(pid);
 501  501        icmp6->icmp6_seq = htons(seq);
 502  502        seq++;
 503  503        icmp6->icmp6_cksum = 0;
 504  504        gettimeofday(&tv, NULL);
 505  505        memcpy(sendbuf + sizeof(struct icmp6_hdr), &tv, sizeof(tv));
 506  506        plen = sizeof(struct icmp6_hdr) + sizeof(tv);
 507  507        n = sendto(fd, sendbuf, plen, 0, (struct sockaddr*) him, sizeof(struct sockaddr_in6));
 508  508        if (n < 0 && errno != EINPROGRESS) {
      509 +#ifdef __linux__
      510 +        if (errno == EINVAL) {
      511 +          /*
      512 +           * On some Linuxes, when bound to the loopback interface, sendto
      513 +           * will fail and errno will be set to EINVAL. When that happens,
      514 +           * don't throw an exception, just return false.
      515 +           */
      516 +          close(fd);
      517 +          return JNI_FALSE;
      518 +        }
      519 +#endif /*__linux__ */
 509  520          NET_ThrowNew(env, errno, "Can't send ICMP packet");
      521 +        close(fd);
 510  522          return JNI_FALSE;
 511  523        }
 512  524  
 513  525        tmout2 = timeout > 1000 ? 1000 : timeout;
 514  526        do {
 515  527          tmout2 = NET_Wait(env, fd, NET_WAIT_READ, tmout2);
 516  528  
 517  529          if (tmout2 >= 0) {
 518  530            len = sizeof(sa_recv);
 519  531            n = recvfrom(fd, recvbuf, sizeof(recvbuf), 0, (struct sockaddr*) &sa_recv, &len);
↓ open down ↓ 187 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX