OSSP CVS Repository

ossp - Difference in ossp-pkg/pth/pth_high.c versions 1.89 and 1.90
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/pth/pth_high.c 1.89 -> 1.90

--- pth_high.c   2002/10/23 14:04:00     1.89
+++ pth_high.c   2002/10/24 09:07:51     1.90
@@ -297,8 +297,8 @@
     pth_implicit_init();
     pth_debug2("pth_select_ev: called from thread \"%s\"", pth_current->name);
 
-    /* sanity checking */
-    if (!pth_util_fd_valid(nfd-1))
+    /* POSIX compliance */
+    if (nfd < 0 || nfd > FD_SETSIZE)
         return_errno(-1, EINVAL);
 
     /* first deal with the special situation of a plain microsecond delay */
@@ -544,6 +544,10 @@
     pth_implicit_init();
     pth_debug2("pth_connect_ev: enter from thread \"%s\"", pth_current->name);
 
+    /* POSIX compliance */
+    if (!pth_util_fd_valid(s))
+        return_errno(-1, EBADF);
+
     /* force filedescriptor into non-blocking mode */
     fdmode = pth_fdmode(s, PTH_FDMODE_NONBLOCK);
 
@@ -595,6 +599,10 @@
     pth_implicit_init();
     pth_debug2("pth_accept_ev: enter from thread \"%s\"", pth_current->name);
 
+    /* POSIX compliance */
+    if (!pth_util_fd_valid(s))
+        return_errno(-1, EBADF);
+
     /* force filedescriptor into non-blocking mode */
     fdmode = pth_fdmode(s, PTH_FDMODE_NONBLOCK);
 
@@ -653,6 +661,8 @@
     /* POSIX compliance */
     if (nbytes == 0)
         return 0;
+    if (!pth_util_fd_valid(fd))
+        return_errno(-1, EBADF);
 
     /* poll filedescriptor if not already in non-blocking operation */
     if (pth_fdmode(fd, PTH_FDMODE_POLL) == PTH_FDMODE_BLOCK) {
@@ -660,8 +670,6 @@
         /* now directly poll filedescriptor for readability
            to avoid unneccessary (and resource consuming because of context
            switches, etc) event handling through the scheduler */
-        if (!pth_util_fd_valid(fd))
-            return_errno(-1, EBADF);
         FD_ZERO(&fds);
         FD_SET(fd, &fds);
         delay.tv_sec  = 0;
@@ -720,6 +728,8 @@
     /* POSIX compliance */
     if (nbytes == 0)
         return 0;
+    if (!pth_util_fd_valid(fd))
+        return_errno(-1, EBADF);
 
     /* force filedescriptor into non-blocking mode */
     fdmode = pth_fdmode(fd, PTH_FDMODE_NONBLOCK);
@@ -730,10 +740,6 @@
         /* now directly poll filedescriptor for writeability
            to avoid unneccessary (and resource consuming because of context
            switches, etc) event handling through the scheduler */
-        if (!pth_util_fd_valid(fd)) {
-            pth_fdmode(fd, fdmode);
-            return_errno(-1, EBADF);
-        }
         FD_ZERO(&fds);
         FD_SET(fd, &fds);
         delay.tv_sec  = 0;
@@ -817,6 +823,8 @@
     /* POSIX compliance */
     if (iovcnt <= 0 || iovcnt > UIO_MAXIOV)
         return_errno(-1, EINVAL);
+    if (!pth_util_fd_valid(fd))
+        return_errno(-1, EBADF);
 
     /* poll filedescriptor if not already in non-blocking operation */
     if (pth_fdmode(fd, PTH_FDMODE_POLL) == PTH_FDMODE_BLOCK) {
@@ -824,8 +832,6 @@
         /* first directly poll filedescriptor for readability
            to avoid unneccessary (and resource consuming because of context
            switches, etc) event handling through the scheduler */
-        if (!pth_util_fd_valid(fd))
-            return_errno(-1, EBADF);
         FD_ZERO(&fds);
         FD_SET(fd, &fds);
         delay.tv_sec  = 0;
@@ -939,6 +945,8 @@
     /* POSIX compliance */
     if (iovcnt <= 0 || iovcnt > UIO_MAXIOV)
         return_errno(-1, EINVAL);
+    if (!pth_util_fd_valid(fd))
+        return_errno(-1, EBADF);
 
     /* force filedescriptor into non-blocking mode */
     fdmode = pth_fdmode(fd, PTH_FDMODE_NONBLOCK);
@@ -968,12 +976,6 @@
         /* first directly poll filedescriptor for writeability
            to avoid unneccessary (and resource consuming because of context
            switches, etc) event handling through the scheduler */
-        if (!pth_util_fd_valid(fd)) {
-            pth_fdmode(fd, fdmode);
-            if (iovcnt > sizeof(tiov_stack))
-                free(tiov);
-            return_errno(-1, EBADF);
-        }
         FD_ZERO(&fds);
         FD_SET(fd, &fds);
         delay.tv_sec  = 0;
@@ -1244,6 +1246,8 @@
     /* POSIX compliance */
     if (nbytes == 0)
         return 0;
+    if (!pth_util_fd_valid(fd))
+        return_errno(-1, EBADF);
 
     /* poll filedescriptor if not already in non-blocking operation */
     if (pth_fdmode(fd, PTH_FDMODE_POLL) == PTH_FDMODE_BLOCK) {
@@ -1323,6 +1327,8 @@
     /* POSIX compliance */
     if (nbytes == 0)
         return 0;
+    if (!pth_util_fd_valid(fd))
+        return_errno(-1, EBADF);
 
     /* force filedescriptor into non-blocking mode */
     fdmode = pth_fdmode(fd, PTH_FDMODE_NONBLOCK);

CVSTrac 2.0.1