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 +#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 +          close(fd);
      392 +          return JNI_FALSE;
      393 +        }
      394 +#endif /*__linux__ */
 384  395          NET_ThrowNew(env, errno, "Can't send ICMP packet");
 385  396          close(fd);
 386  397          return JNI_FALSE;
 387  398        }
 388  399  
 389  400        tmout2 = timeout > 1000 ? 1000 : timeout;
 390  401        do {
 391  402          tmout2 = NET_Wait(env, fd, NET_WAIT_READ, tmout2);
 392  403          if (tmout2 >= 0) {
 393  404            len = sizeof(sa_recv);
↓ open down ↓ 175 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX