From 84760ec8445096b196a32d65fa64429f826a2cdc Mon Sep 17 00:00:00 2001 From: darkcoven Date: Tue, 8 Apr 2014 19:31:39 +0200 Subject: [PATCH] Fix handling of timeout errors --- lib/src/network.c | 10 +++++++--- raw/src/net.c | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) 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); -- 2.39.5