hotspot/src/os/solaris/vm/os_solaris.cpp
changeset 11256 025cd1741566
parent 11161 ec855b5a23c2
child 11259 f3c6f6231de5
equal deleted inserted replaced
11255:7d28e253b4b0 11256:025cd1741566
  6361 
  6361 
  6362 int os::socket_close(int fd) {
  6362 int os::socket_close(int fd) {
  6363   RESTARTABLE_RETURN_INT(::close(fd));
  6363   RESTARTABLE_RETURN_INT(::close(fd));
  6364 }
  6364 }
  6365 
  6365 
  6366 int os::recv(int fd, char *buf, int nBytes, int flags) {
  6366 int os::recv(int fd, char* buf, size_t nBytes, uint flags) {
  6367   INTERRUPTIBLE_RETURN_INT(::recv(fd, buf, nBytes, flags), os::Solaris::clear_interrupted);
  6367   INTERRUPTIBLE_RETURN_INT((int)::recv(fd, buf, nBytes, flags), os::Solaris::clear_interrupted);
  6368 }
  6368 }
  6369 
  6369 
  6370 
  6370 int os::send(int fd, char* buf, size_t nBytes, uint flags) {
  6371 int os::send(int fd, char *buf, int nBytes, int flags) {
  6371   INTERRUPTIBLE_RETURN_INT((int)::send(fd, buf, nBytes, flags), os::Solaris::clear_interrupted);
  6372   INTERRUPTIBLE_RETURN_INT(::send(fd, buf, nBytes, flags), os::Solaris::clear_interrupted);
  6372 }
  6373 }
  6373 
  6374 
  6374 int os::raw_send(int fd, char* buf, size_t nBytes, uint flags) {
  6375 int os::raw_send(int fd, char *buf, int nBytes, int flags) {
  6375   RESTARTABLE_RETURN_INT((int)::send(fd, buf, nBytes, flags));
  6376   RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, flags));
       
  6377 }
  6376 }
  6378 
  6377 
  6379 // As both poll and select can be interrupted by signals, we have to be
  6378 // As both poll and select can be interrupted by signals, we have to be
  6380 // prepared to restart the system call after updating the timeout, unless
  6379 // prepared to restart the system call after updating the timeout, unless
  6381 // a poll() is done with timeout == -1, in which case we repeat with this
  6380 // a poll() is done with timeout == -1, in which case we repeat with this
  6406         }
  6405         }
  6407     } else return res;
  6406     } else return res;
  6408   }
  6407   }
  6409 }
  6408 }
  6410 
  6409 
  6411 int os::connect(int fd, struct sockaddr *him, int len) {
  6410 int os::connect(int fd, struct sockaddr *him, socklen_t len) {
  6412   int _result;
  6411   int _result;
  6413   INTERRUPTIBLE_NORESTART(::connect(fd, him, len), _result,
  6412   INTERRUPTIBLE_NORESTART(::connect(fd, him, len), _result,\
  6414                           os::Solaris::clear_interrupted);
  6413                           os::Solaris::clear_interrupted);
  6415 
  6414 
  6416   // Depending on when thread interruption is reset, _result could be
  6415   // Depending on when thread interruption is reset, _result could be
  6417   // one of two values when errno == EINTR
  6416   // one of two values when errno == EINTR
  6418 
  6417 
  6419   if (((_result == OS_INTRPT) || (_result == OS_ERR))
  6418   if (((_result == OS_INTRPT) || (_result == OS_ERR))
  6420                                         && (errno == EINTR)) {
  6419       && (errno == EINTR)) {
  6421      /* restarting a connect() changes its errno semantics */
  6420      /* restarting a connect() changes its errno semantics */
  6422      INTERRUPTIBLE(::connect(fd, him, len), _result,
  6421      INTERRUPTIBLE(::connect(fd, him, len), _result,\
  6423                      os::Solaris::clear_interrupted);
  6422                    os::Solaris::clear_interrupted);
  6424      /* undo these changes */
  6423      /* undo these changes */
  6425      if (_result == OS_ERR) {
  6424      if (_result == OS_ERR) {
  6426        if (errno == EALREADY) {
  6425        if (errno == EALREADY) {
  6427          errno = EINPROGRESS; /* fall through */
  6426          errno = EINPROGRESS; /* fall through */
  6428        } else if (errno == EISCONN) {
  6427        } else if (errno == EISCONN) {
  6432      }
  6431      }
  6433    }
  6432    }
  6434    return _result;
  6433    return _result;
  6435  }
  6434  }
  6436 
  6435 
  6437 int os::accept(int fd, struct sockaddr *him, int *len) {
  6436 int os::accept(int fd, struct sockaddr* him, socklen_t* len) {
  6438   if (fd < 0)
  6437   if (fd < 0) {
  6439    return OS_ERR;
  6438     return OS_ERR;
  6440   INTERRUPTIBLE_RETURN_INT((int)::accept(fd, him,\
  6439   }
  6441     (socklen_t*) len), os::Solaris::clear_interrupted);
  6440   INTERRUPTIBLE_RETURN_INT((int)::accept(fd, him, len),\
  6442  }
  6441                            os::Solaris::clear_interrupted);
  6443 
  6442 }
  6444 int os::recvfrom(int fd, char *buf, int nBytes, int flags,
  6443 
  6445                              sockaddr *from, int *fromlen) {
  6444 int os::recvfrom(int fd, char* buf, size_t nBytes, uint flags,
  6446    //%%note jvm_r11
  6445                  sockaddr* from, socklen_t* fromlen) {
  6447   INTERRUPTIBLE_RETURN_INT((int)::recvfrom(fd, buf, nBytes,\
  6446   INTERRUPTIBLE_RETURN_INT((int)::recvfrom(fd, buf, nBytes, flags, from, fromlen),\
  6448     flags, from, fromlen), os::Solaris::clear_interrupted);
  6447                            os::Solaris::clear_interrupted);
  6449 }
  6448 }
  6450 
  6449 
  6451 int os::sendto(int fd, char *buf, int len, int flags,
  6450 int os::sendto(int fd, char* buf, size_t len, uint flags,
  6452                            struct sockaddr *to, int tolen) {
  6451                struct sockaddr* to, socklen_t tolen) {
  6453   //%%note jvm_r11
  6452   INTERRUPTIBLE_RETURN_INT((int)::sendto(fd, buf, len, flags, to, tolen),\
  6454   INTERRUPTIBLE_RETURN_INT((int)::sendto(fd, buf, len, flags,\
  6453                            os::Solaris::clear_interrupted);
  6455     to, tolen), os::Solaris::clear_interrupted);
       
  6456 }
  6454 }
  6457 
  6455 
  6458 int os::socket_available(int fd, jint *pbytes) {
  6456 int os::socket_available(int fd, jint *pbytes) {
  6459    if (fd < 0)
  6457   if (fd < 0) {
  6460      return OS_OK;
  6458     return OS_OK;
  6461 
  6459   }
  6462    int ret;
  6460   int ret;
  6463 
  6461   RESTARTABLE(::ioctl(fd, FIONREAD, pbytes), ret);
  6464    RESTARTABLE(::ioctl(fd, FIONREAD, pbytes), ret);
  6462   // note: ioctl can return 0 when successful, JVM_SocketAvailable
  6465 
  6463   // is expected to return 0 on failure and 1 on success to the jdk.
  6466    //%% note ioctl can return 0 when successful, JVM_SocketAvailable
  6464   return (ret == OS_ERR) ? 0 : 1;
  6467    // is expected to return 0 on failure and 1 on success to the jdk.
  6465 }
  6468 
  6466 
  6469    return (ret == OS_ERR) ? 0 : 1;
  6467 int os::bind(int fd, struct sockaddr* him, socklen_t len) {
  6470 }
       
  6471 
       
  6472 
       
  6473 int os::bind(int fd, struct sockaddr *him, int len) {
       
  6474    INTERRUPTIBLE_RETURN_INT_NORESTART(::bind(fd, him, len),\
  6468    INTERRUPTIBLE_RETURN_INT_NORESTART(::bind(fd, him, len),\
  6475      os::Solaris::clear_interrupted);
  6469                                       os::Solaris::clear_interrupted);
  6476 }
  6470 }