equal
deleted
inserted
replaced
735 } |
735 } |
736 } |
736 } |
737 return 0; |
737 return 0; |
738 } |
738 } |
739 |
739 |
740 void initLocalAddrTable () { |
740 void platformInit () { |
741 initLoopbackRoutes(); |
741 initLoopbackRoutes(); |
742 initLocalIfs(); |
742 initLocalIfs(); |
743 } |
743 } |
744 |
744 |
|
745 #elif defined(_AIX) |
|
746 |
|
747 /* Initialize stubs for blocking I/O workarounds (see src/solaris/native/java/net/linux_close.c) */ |
|
748 extern void aix_close_init(); |
|
749 |
|
750 void platformInit () { |
|
751 aix_close_init(); |
|
752 } |
|
753 |
745 #else |
754 #else |
746 |
755 |
747 void initLocalAddrTable () {} |
756 void platformInit () {} |
748 |
757 |
749 #endif |
758 #endif |
750 |
759 |
751 void parseExclusiveBindProperty(JNIEnv *env) { |
760 void parseExclusiveBindProperty(JNIEnv *env) { |
752 #ifdef __solaris__ |
761 #ifdef __solaris__ |
1269 */ |
1278 */ |
1270 int |
1279 int |
1271 NET_SetSockOpt(int fd, int level, int opt, const void *arg, |
1280 NET_SetSockOpt(int fd, int level, int opt, const void *arg, |
1272 int len) |
1281 int len) |
1273 { |
1282 { |
|
1283 |
1274 #ifndef IPTOS_TOS_MASK |
1284 #ifndef IPTOS_TOS_MASK |
1275 #define IPTOS_TOS_MASK 0x1e |
1285 #define IPTOS_TOS_MASK 0x1e |
1276 #endif |
1286 #endif |
1277 #ifndef IPTOS_PREC_MASK |
1287 #ifndef IPTOS_PREC_MASK |
1278 #define IPTOS_PREC_MASK 0xe0 |
1288 #define IPTOS_PREC_MASK 0xe0 |
1289 #ifdef __APPLE__ |
1299 #ifdef __APPLE__ |
1290 static int maxsockbuf = -1; |
1300 static int maxsockbuf = -1; |
1291 #else |
1301 #else |
1292 static long maxsockbuf = -1; |
1302 static long maxsockbuf = -1; |
1293 #endif |
1303 #endif |
1294 |
|
1295 int addopt; |
|
1296 struct linger *ling; |
|
1297 #endif |
1304 #endif |
1298 |
1305 |
1299 /* |
1306 /* |
1300 * IPPROTO/IP_TOS :- |
1307 * IPPROTO/IP_TOS :- |
1301 * 1. IPv6 on Solaris/Mac OS: NOOP and will be set |
1308 * 1. IPv6 on Solaris/Mac OS: NOOP and will be set |
1384 } |
1391 } |
1385 } |
1392 } |
1386 } |
1393 } |
1387 #endif |
1394 #endif |
1388 |
1395 |
|
1396 #ifdef _AIX |
|
1397 if (level == SOL_SOCKET) { |
|
1398 if (opt == SO_SNDBUF || opt == SO_RCVBUF) { |
|
1399 /* |
|
1400 * Just try to set the requested size. If it fails we will leave the |
|
1401 * socket option as is. Setting the buffer size means only a hint in |
|
1402 * the jse2/java software layer, see javadoc. In the previous |
|
1403 * solution the buffer has always been truncated to a length of |
|
1404 * 0x100000 Byte, even if the technical limit has not been reached. |
|
1405 * This kind of absolute truncation was unexpected in the jck tests. |
|
1406 */ |
|
1407 int ret = setsockopt(fd, level, opt, arg, len); |
|
1408 if ((ret == 0) || (ret == -1 && errno == ENOBUFS)) { |
|
1409 // Accept failure because of insufficient buffer memory resources. |
|
1410 return 0; |
|
1411 } else { |
|
1412 // Deliver all other kinds of errors. |
|
1413 return ret; |
|
1414 } |
|
1415 } |
|
1416 } |
|
1417 #endif |
|
1418 |
1389 /* |
1419 /* |
1390 * On Linux the receive buffer is used for both socket |
1420 * On Linux the receive buffer is used for both socket |
1391 * structures and the the packet payload. The implication |
1421 * structures and the the packet payload. The implication |
1392 * is that if SO_RCVBUF is too small then small packets |
1422 * is that if SO_RCVBUF is too small then small packets |
1393 * must be discard. |
1423 * must be discard. |
1440 *bufsize = 1024; |
1470 *bufsize = 1024; |
1441 } |
1471 } |
1442 |
1472 |
1443 } |
1473 } |
1444 } |
1474 } |
1445 |
1475 #endif |
|
1476 |
|
1477 #if defined(_ALLBSD_SOURCE) || defined(_AIX) |
1446 /* |
1478 /* |
1447 * On Solaris, SO_REUSEADDR will allow multiple datagram |
1479 * On Solaris, SO_REUSEADDR will allow multiple datagram |
1448 * sockets to bind to the same port. The network jck tests |
1480 * sockets to bind to the same port. The network jck tests check |
1449 * for this "feature", so we need to emulate it by turning on |
1481 * for this "feature", so we need to emulate it by turning on |
1450 * SO_REUSEPORT as well for that combination. |
1482 * SO_REUSEPORT as well for that combination. |
1451 */ |
1483 */ |
1452 if (level == SOL_SOCKET && opt == SO_REUSEADDR) { |
1484 if (level == SOL_SOCKET && opt == SO_REUSEADDR) { |
1453 int sotype; |
1485 int sotype; |
1457 if (getsockopt(fd, SOL_SOCKET, SO_TYPE, (void *)&sotype, &arglen) < 0) { |
1489 if (getsockopt(fd, SOL_SOCKET, SO_TYPE, (void *)&sotype, &arglen) < 0) { |
1458 return -1; |
1490 return -1; |
1459 } |
1491 } |
1460 |
1492 |
1461 if (sotype == SOCK_DGRAM) { |
1493 if (sotype == SOCK_DGRAM) { |
1462 addopt = SO_REUSEPORT; |
1494 setsockopt(fd, level, SO_REUSEPORT, arg, len); |
1463 setsockopt(fd, level, addopt, arg, len); |
1495 } |
1464 } |
1496 } |
1465 } |
|
1466 |
|
1467 #endif |
1497 #endif |
1468 |
1498 |
1469 return setsockopt(fd, level, opt, arg, len); |
1499 return setsockopt(fd, level, opt, arg, len); |
1470 } |
1500 } |
1471 |
1501 |
1631 newTime = JVM_CurrentTimeMillis(env, 0); |
1661 newTime = JVM_CurrentTimeMillis(env, 0); |
1632 timeout -= (newTime - prevTime); |
1662 timeout -= (newTime - prevTime); |
1633 if (timeout <= 0) { |
1663 if (timeout <= 0) { |
1634 return read_rv > 0 ? 0 : -1; |
1664 return read_rv > 0 ? 0 : -1; |
1635 } |
1665 } |
1636 newTime = prevTime; |
1666 prevTime = newTime; |
1637 |
1667 |
1638 if (read_rv > 0) { |
1668 if (read_rv > 0) { |
1639 break; |
1669 break; |
1640 } |
1670 } |
1641 |
1671 |