jdk/src/solaris/native/java/net/bsd_close.c
changeset 23048 cf8cda42cd52
parent 23043 15face72cb3b
equal deleted inserted replaced
23047:e7dcfb17bf53 23048:cf8cda42cd52
    35 #include <sys/resource.h>
    35 #include <sys/resource.h>
    36 #include <sys/uio.h>
    36 #include <sys/uio.h>
    37 #include <unistd.h>
    37 #include <unistd.h>
    38 #include <errno.h>
    38 #include <errno.h>
    39 #include <sys/poll.h>
    39 #include <sys/poll.h>
    40 
       
    41 #include "jni_util.h"
       
    42 
    40 
    43 /*
    41 /*
    44  * Stack allocated by thread when doing blocking operation
    42  * Stack allocated by thread when doing blocking operation
    45  */
    43  */
    46 typedef struct threadEntry {
    44 typedef struct threadEntry {
   331 /*
   329 /*
   332  * Wrapper for select(s, timeout). We are using select() on Mac OS due to Bug 7131399.
   330  * Wrapper for select(s, timeout). We are using select() on Mac OS due to Bug 7131399.
   333  * Auto restarts with adjusted timeout if interrupted by
   331  * Auto restarts with adjusted timeout if interrupted by
   334  * signal other than our wakeup signal.
   332  * signal other than our wakeup signal.
   335  */
   333  */
   336 int NET_Timeout(JNIEnv *env, int s, long timeout) {
   334 int NET_Timeout(int s, long timeout) {
   337     long prevtime = 0, newtime;
   335     long prevtime = 0, newtime;
   338     struct timeval t, *tp = &t;
   336     struct timeval t, *tp = &t;
   339     fd_set fds;
   337     fd_set fds;
   340     fd_set* fdsp = NULL;
   338     fd_set* fdsp = NULL;
   341     int allocated = 0;
   339     int allocated = 0;
   374         FD_ZERO(fdsp);
   372         FD_ZERO(fdsp);
   375     } else {
   373     } else {
   376         int length = (howmany(s+1, NFDBITS)) * sizeof(int);
   374         int length = (howmany(s+1, NFDBITS)) * sizeof(int);
   377         fdsp = (fd_set *) calloc(1, length);
   375         fdsp = (fd_set *) calloc(1, length);
   378         if (fdsp == NULL) {
   376         if (fdsp == NULL) {
   379             JNU_ThrowOutOfMemoryError(env, "NET_Select native heap allocation failed");
   377             return -1;   // errno will be set to ENOMEM
   380             return 0;
       
   381         }
   378         }
   382         allocated = 1;
   379         allocated = 1;
   383     }
   380     }
   384     FD_SET(s, fdsp);
   381     FD_SET(s, fdsp);
   385 
   382