]> git.sur5r.net Git - ngadmin/commitdiff
Fix handling of timeout errors
authordarkcoven <admin@darkcoven.tk>
Tue, 8 Apr 2014 17:31:39 +0000 (19:31 +0200)
committerdarkcoven <admin@darkcoven.tk>
Tue, 8 Apr 2014 18:57:09 +0000 (20:57 +0200)
lib/src/network.c
raw/src/net.c

index e62b5b89c23fe085433c409cb99351f813f74311..be91126f207975886c19fbadae51d13ccfee1b64 100644 (file)
@@ -241,12 +241,14 @@ int readRequest (struct ngadmin *nga, List *attr)
        if (i == -EINVAL) {
                ret = ERR_INVARG;
                goto end;
+       } else if (i == -ETIMEDOUT) {
+               ret = ERR_TIMEOUT;
+               goto end;
        } else if (i < 0) {
-               ret = (errno == EAGAIN || errno == EWOULDBLOCK) ? ERR_TIMEOUT : ERR_NET;
+               ret = ERR_NET;
                goto end;
        }
        
-       
        /* check the switch error code */
        ret = checkErrorCode(&nc);
        
@@ -300,8 +302,10 @@ int writeRequest (struct ngadmin *nga, List *attr)
        if (i == -EINVAL) {
                ret = ERR_INVARG;
                goto end;
+       } else if (i == -ETIMEDOUT) {
+               ret = ERR_TIMEOUT;
        } else if (i < 0) {
-               ret = (errno == EAGAIN || errno == EWOULDBLOCK) ? ERR_TIMEOUT : ERR_NET;
+               ret = ERR_NET;
                goto end;
        }
        
index 83a69f3c9ad68a4f9405676e7798354a6de4b20e..78bf4ac419b9a8245c83eba3b6924c6b287f1552 100644 (file)
@@ -116,8 +116,10 @@ int recvNsdpPacket (int sock, struct nsdp_cmd *nc, List *attr, const struct time
                        timeval_to_timespec(&timeend, &tv);
 #endif
                        timewait = timespec_diff_ms(&timecurrent, &timeend);
-                       if (timewait <= 0)
+                       if (timewait <= 0) {
+                               len = -ETIMEDOUT;
                                break;
+                       }
                }
                
                len = poll(&fds, 1, timewait);