comparison src/os/solaris/vm/os_solaris.cpp @ 4720:4b18532913c7

Merge
author vladidan
date Thu, 22 Dec 2011 12:01:46 -0500
parents e7dead7e90af 11c26bfcf8c7
children 20bfb6d15a94
comparison
equal deleted inserted replaced
4713:129cd462ae89 4720:4b18532913c7
6357 6357
6358 int os::socket_close(int fd) { 6358 int os::socket_close(int fd) {
6359 RESTARTABLE_RETURN_INT(::close(fd)); 6359 RESTARTABLE_RETURN_INT(::close(fd));
6360 } 6360 }
6361 6361
6362 int os::recv(int fd, char *buf, int nBytes, int flags) { 6362 int os::recv(int fd, char* buf, size_t nBytes, uint flags) {
6363 INTERRUPTIBLE_RETURN_INT(::recv(fd, buf, nBytes, flags), os::Solaris::clear_interrupted); 6363 INTERRUPTIBLE_RETURN_INT((int)::recv(fd, buf, nBytes, flags), os::Solaris::clear_interrupted);
6364 } 6364 }
6365 6365
6366 6366 int os::send(int fd, char* buf, size_t nBytes, uint flags) {
6367 int os::send(int fd, char *buf, int nBytes, int flags) { 6367 INTERRUPTIBLE_RETURN_INT((int)::send(fd, buf, nBytes, flags), os::Solaris::clear_interrupted);
6368 INTERRUPTIBLE_RETURN_INT(::send(fd, buf, nBytes, flags), os::Solaris::clear_interrupted); 6368 }
6369 } 6369
6370 6370 int os::raw_send(int fd, char* buf, size_t nBytes, uint flags) {
6371 int os::raw_send(int fd, char *buf, int nBytes, int flags) { 6371 RESTARTABLE_RETURN_INT((int)::send(fd, buf, nBytes, flags));
6372 RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, flags));
6373 } 6372 }
6374 6373
6375 // As both poll and select can be interrupted by signals, we have to be 6374 // As both poll and select can be interrupted by signals, we have to be
6376 // prepared to restart the system call after updating the timeout, unless 6375 // prepared to restart the system call after updating the timeout, unless
6377 // a poll() is done with timeout == -1, in which case we repeat with this 6376 // a poll() is done with timeout == -1, in which case we repeat with this
6402 } 6401 }
6403 } else return res; 6402 } else return res;
6404 } 6403 }
6405 } 6404 }
6406 6405
6407 int os::connect(int fd, struct sockaddr *him, int len) { 6406 int os::connect(int fd, struct sockaddr *him, socklen_t len) {
6408 int _result; 6407 int _result;
6409 INTERRUPTIBLE_NORESTART(::connect(fd, him, len), _result, 6408 INTERRUPTIBLE_NORESTART(::connect(fd, him, len), _result,\
6410 os::Solaris::clear_interrupted); 6409 os::Solaris::clear_interrupted);
6411 6410
6412 // Depending on when thread interruption is reset, _result could be 6411 // Depending on when thread interruption is reset, _result could be
6413 // one of two values when errno == EINTR 6412 // one of two values when errno == EINTR
6414 6413
6415 if (((_result == OS_INTRPT) || (_result == OS_ERR)) 6414 if (((_result == OS_INTRPT) || (_result == OS_ERR))
6416 && (errno == EINTR)) { 6415 && (errno == EINTR)) {
6417 /* restarting a connect() changes its errno semantics */ 6416 /* restarting a connect() changes its errno semantics */
6418 INTERRUPTIBLE(::connect(fd, him, len), _result, 6417 INTERRUPTIBLE(::connect(fd, him, len), _result,\
6419 os::Solaris::clear_interrupted); 6418 os::Solaris::clear_interrupted);
6420 /* undo these changes */ 6419 /* undo these changes */
6421 if (_result == OS_ERR) { 6420 if (_result == OS_ERR) {
6422 if (errno == EALREADY) { 6421 if (errno == EALREADY) {
6423 errno = EINPROGRESS; /* fall through */ 6422 errno = EINPROGRESS; /* fall through */
6424 } else if (errno == EISCONN) { 6423 } else if (errno == EISCONN) {
6428 } 6427 }
6429 } 6428 }
6430 return _result; 6429 return _result;
6431 } 6430 }
6432 6431
6433 int os::accept(int fd, struct sockaddr *him, int *len) { 6432 int os::accept(int fd, struct sockaddr* him, socklen_t* len) {
6434 if (fd < 0) 6433 if (fd < 0) {
6435 return OS_ERR; 6434 return OS_ERR;
6436 INTERRUPTIBLE_RETURN_INT((int)::accept(fd, him,\ 6435 }
6437 (socklen_t*) len), os::Solaris::clear_interrupted); 6436 INTERRUPTIBLE_RETURN_INT((int)::accept(fd, him, len),\
6438 } 6437 os::Solaris::clear_interrupted);
6439 6438 }
6440 int os::recvfrom(int fd, char *buf, int nBytes, int flags, 6439
6441 sockaddr *from, int *fromlen) { 6440 int os::recvfrom(int fd, char* buf, size_t nBytes, uint flags,
6442 //%%note jvm_r11 6441 sockaddr* from, socklen_t* fromlen) {
6443 INTERRUPTIBLE_RETURN_INT((int)::recvfrom(fd, buf, nBytes,\ 6442 INTERRUPTIBLE_RETURN_INT((int)::recvfrom(fd, buf, nBytes, flags, from, fromlen),\
6444 flags, from, fromlen), os::Solaris::clear_interrupted); 6443 os::Solaris::clear_interrupted);
6445 } 6444 }
6446 6445
6447 int os::sendto(int fd, char *buf, int len, int flags, 6446 int os::sendto(int fd, char* buf, size_t len, uint flags,
6448 struct sockaddr *to, int tolen) { 6447 struct sockaddr* to, socklen_t tolen) {
6449 //%%note jvm_r11 6448 INTERRUPTIBLE_RETURN_INT((int)::sendto(fd, buf, len, flags, to, tolen),\
6450 INTERRUPTIBLE_RETURN_INT((int)::sendto(fd, buf, len, flags,\ 6449 os::Solaris::clear_interrupted);
6451 to, tolen), os::Solaris::clear_interrupted);
6452 } 6450 }
6453 6451
6454 int os::socket_available(int fd, jint *pbytes) { 6452 int os::socket_available(int fd, jint *pbytes) {
6455 if (fd < 0) 6453 if (fd < 0) {
6456 return OS_OK; 6454 return OS_OK;
6457 6455 }
6458 int ret; 6456 int ret;
6459 6457 RESTARTABLE(::ioctl(fd, FIONREAD, pbytes), ret);
6460 RESTARTABLE(::ioctl(fd, FIONREAD, pbytes), ret); 6458 // note: ioctl can return 0 when successful, JVM_SocketAvailable
6461 6459 // is expected to return 0 on failure and 1 on success to the jdk.
6462 //%% note ioctl can return 0 when successful, JVM_SocketAvailable 6460 return (ret == OS_ERR) ? 0 : 1;
6463 // is expected to return 0 on failure and 1 on success to the jdk. 6461 }
6464 6462
6465 return (ret == OS_ERR) ? 0 : 1; 6463 int os::bind(int fd, struct sockaddr* him, socklen_t len) {
6466 }
6467
6468
6469 int os::bind(int fd, struct sockaddr *him, int len) {
6470 INTERRUPTIBLE_RETURN_INT_NORESTART(::bind(fd, him, len),\ 6464 INTERRUPTIBLE_RETURN_INT_NORESTART(::bind(fd, him, len),\
6471 os::Solaris::clear_interrupted); 6465 os::Solaris::clear_interrupted);
6472 } 6466 }