OSSP CVS Repository

ossp - Check-in [1128]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 1128
Date: 2001-Oct-09 20:34:12 (local)
2001-Oct-09 18:34:12 (UTC)
User:rse
Branch:
Comment: Change return code semantic for timeouts from "rv == SA_ERR_SYS && errno == ETIMEDOUT" to a dedicated timeout return value "rv == SA_ERR_TMT".
Tickets:
Inspections:
Files:
ossp-pkg/sa/TODO      1.16 -> 1.17     0 inserted, 1 deleted
ossp-pkg/sa/sa.c      1.18 -> 1.19     19 inserted, 6 deleted
ossp-pkg/sa/sa.h      1.17 -> 1.18     1 inserted, 0 deleted

ossp-pkg/sa/TODO 1.16 -> 1.17

--- TODO 2001/10/09 18:27:13     1.16
+++ TODO 2001/10/09 18:34:12     1.17
@@ -1,5 +1,4 @@
 
-- perhaps change rv=SA_ERR_SYS+errno=ETIMEDOUT to rv=SA_ERR_TIMEOUT;
 - support for writev(2)
 - perhaps move 1024-buffer of writef into sa_t and make adjustable
 - sa_buffer(sa, <which>, size)


ossp-pkg/sa/sa.c 1.18 -> 1.19

--- sa.c 2001/10/09 18:26:12     1.18
+++ sa.c 2001/10/09 18:34:12     1.19
@@ -1134,7 +1134,7 @@
             goto done;
         }
         else if (n == 0) {
-            error = ETIMEDOUT;
+            rv = SA_ERR_TMT;
             goto done;
         }
 
@@ -1216,7 +1216,7 @@
                              &sa->tvTimeout[SA_TIMEOUT_ACCEPT]);
         } while (n == -1 && errno == EINTR);
         if (n == 0) 
-            errno = ETIMEDOUT;
+            return SA_ERR_TMT;
         if (n <= 0)
             return SA_ERR_SYS;
     }
@@ -1413,6 +1413,8 @@
         res = sa_read_raw(sa, cpBuf, nBufReq);
         if (res == 0)
             rv = SA_ERR_EOF;
+        else if (res < 0 && errno == ETIMEDOUT)
+            rv = SA_ERR_TMT;
         else if (res < 0)
             rv = SA_ERR_SYS;
     }
@@ -1443,13 +1445,18 @@
                         res += n;
                     else if (n == 0)
                         rv = (res == 0 ? SA_ERR_EOF : SA_OK);
+                    else if (n < 0 && errno == ETIMEDOUT)
+                        rv = (res == 0 ? SA_ERR_TMT : SA_OK);
                     else if (n < 0)
                         rv = (res == 0 ? SA_ERR_SYS : SA_OK);
                 }
                 else {
                     /* fill buffer with new data */
                     n = sa_read_raw(sa, sa->cpReadBuf, sa->nReadSize);
-                    if (n < 0)
+                    if (n < 0 && errno == ETIMEDOUT)
+                        /* timeout on this read, but perhaps ok as a whole */
+                        rv = (res == 0 ? SA_ERR_TMT : SA_OK);
+                    else if (n < 0)
                         /* error on this read, but perhaps ok as a whole */
                         rv = (res == 0 ? SA_ERR_SYS : SA_OK);
                     if (n == 0)
@@ -1565,7 +1572,9 @@
     if (sa->nWriteSize == 0) {
         /* user-space unbuffered I/O */
         res = sa_write_raw(sa, cpBuf, nBufReq);
-        if (res < 0)
+        if (res < 0 && errno == ETIMEDOUT)
+            rv = SA_ERR_TMT;
+        else if (res < 0)
             rv = SA_ERR_SYS;
     }
     else {
@@ -1579,7 +1588,9 @@
             /* buffer too small at all, so write immediately */
             while (nBufReq > 0) {
                 n = sa_write_raw(sa, cpBuf, nBufReq);
-                if (n < 0)
+                if (n < 0 && errno == ETIMEDOUT)
+                    rv = (res == 0 ? SA_ERR_TMT : SA_OK);
+                else if (n < 0)
                     rv = (res == 0 ? SA_ERR_SYS : SA_OK);
                 if (n <= 0)
                     break;
@@ -1657,7 +1668,9 @@
     if (sa->nWriteSize > 0) {
         while (sa->nWriteLen > 0) {
             n = sa_write_raw(sa, sa->cpWriteBuf, sa->nWriteLen);
-            if (n < 0)
+            if (n < 0 && errno == ETIMEDOUT)
+                rv = SA_ERR_TMT;
+            else if (n < 0)
                 rv = SA_ERR_SYS;
             if (n <= 0)
                 break;


ossp-pkg/sa/sa.h 1.17 -> 1.18

--- sa.h 2001/10/09 14:05:55     1.17
+++ sa.h 2001/10/09 18:34:12     1.18
@@ -111,6 +111,7 @@
     SA_ERR_SYS, /* system error (see errno) */
     SA_ERR_EOF, /* end of file/socket communication */
     SA_ERR_MTC, /* error in match */
+    SA_ERR_TMT, /* operation timeout */
     SA_ERR_INT  /* internal error */
 } sa_rc_t;
 

CVSTrac 2.0.1