From: darkcoven Date: Tue, 8 Apr 2014 17:31:39 +0000 (+0200) Subject: Fix handling of timeout errors X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=84760ec8445096b196a32d65fa64429f826a2cdc;p=ngadmin Fix handling of timeout errors --- diff --git a/lib/src/network.c b/lib/src/network.c index e62b5b8..be91126 100644 --- a/lib/src/network.c +++ b/lib/src/network.c @@ -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; } diff --git a/raw/src/net.c b/raw/src/net.c index 83a69f3..78bf4ac 100644 --- a/raw/src/net.c +++ b/raw/src/net.c @@ -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);