Print this page


Split Close
Expand all
Collapse all
          --- old/src/solaris/native/java/net/Inet4AddressImpl.c
          +++ new/src/solaris/native/java/net/Inet4AddressImpl.c
↓ open down ↓ 373 lines elided ↑ open up ↑
 374  374        memcpy(icmp->icmp_data, &tv, sizeof(tv));
 375  375        plen = ICMP_ADVLENMIN + sizeof(tv);
 376  376        icmp->icmp_cksum = 0;
 377  377        icmp->icmp_cksum = in_cksum((u_short *)icmp, plen);
 378  378        /*
 379  379         * send it
 380  380         */
 381  381        n = sendto(fd, sendbuf, plen, 0, (struct sockaddr *)him,
 382  382                   sizeof(struct sockaddr));
 383  383        if (n < 0 && errno != EINPROGRESS ) {
 384      -        NET_ThrowNew(env, errno, "Can't send ICMP packet");
      384 +#ifdef __linux__
      385 +        if (errno == EINVAL) {
      386 +          /*
      387 +           * On some Linuxes, when bound to the loopback interface, sendto
      388 +           * will fail and errno will be set to EINVAL. When that happens,
      389 +           * don't throw an exception, just return false.
      390 +           */
      391 +        } else
      392 +#endif /*__linux__ */
      393 +          NET_ThrowNew(env, errno, "Can't send ICMP packet");
 385  394          close(fd);
 386  395          return JNI_FALSE;
 387  396        }
 388  397  
 389  398        tmout2 = timeout > 1000 ? 1000 : timeout;
 390  399        do {
 391  400          tmout2 = NET_Wait(env, fd, NET_WAIT_READ, tmout2);
 392  401          if (tmout2 >= 0) {
 393  402            len = sizeof(sa_recv);
 394  403            n = recvfrom(fd, recvbuf, sizeof(recvbuf), 0, (struct sockaddr *)&sa_recv, &len);
↓ open down ↓ 174 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX