summaryrefslogtreecommitdiff
path: root/usr/src/boot/lib
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/boot/lib')
-rw-r--r--usr/src/boot/lib/libstand/ip.c9
-rw-r--r--usr/src/boot/lib/libstand/net.c2
-rw-r--r--usr/src/boot/lib/libstand/tftp.c8
3 files changed, 15 insertions, 4 deletions
diff --git a/usr/src/boot/lib/libstand/ip.c b/usr/src/boot/lib/libstand/ip.c
index c920cb7172..789dcaab6f 100644
--- a/usr/src/boot/lib/libstand/ip.c
+++ b/usr/src/boot/lib/libstand/ip.c
@@ -415,8 +415,13 @@ readip(struct iodesc *d, void **pkt, void **payload, time_t tleft,
while ((getsecs() - t) < tleft) {
errno = 0;
ret = readipv4(d, pkt, payload, tleft, proto);
+ if (ret >= 0)
+ return (ret);
+ /* Bubble up the error if it wasn't successful */
if (errno != EAGAIN)
- break;
+ return (-1);
}
- return (ret);
+ /* We've exhausted tleft; timeout */
+ errno = ETIMEDOUT;
+ return (-1);
}
diff --git a/usr/src/boot/lib/libstand/net.c b/usr/src/boot/lib/libstand/net.c
index 740696a5a2..ea4c75b233 100644
--- a/usr/src/boot/lib/libstand/net.c
+++ b/usr/src/boot/lib/libstand/net.c
@@ -117,7 +117,7 @@ sendrecv(struct iodesc *d,
/* Try to get a packet and process it. */
cc = (*rproc)(d, pkt, payload, tleft);
/* Return on data, EOF or real error. */
- if (cc != -1 || errno != 0)
+ if (cc != -1 || (errno != 0 && errno != ETIMEDOUT))
return (cc);
/* Timed out or didn't get the packet we're waiting for */
diff --git a/usr/src/boot/lib/libstand/tftp.c b/usr/src/boot/lib/libstand/tftp.c
index 36ced27a20..39cd1466fe 100644
--- a/usr/src/boot/lib/libstand/tftp.c
+++ b/usr/src/boot/lib/libstand/tftp.c
@@ -637,14 +637,20 @@ sendrecv_tftp(struct tftp_handle *h,
if (cc == -1) {
/* Error on transmit; wait before retrying */
while ((getsecs() - t1) < tleft);
+ t1 = getsecs();
continue;
}
+ t = t1 = getsecs();
recvnext:
+ if ((getsecs() - t) > MAXTMO) {
+ errno = ETIMEDOUT;
+ return (-1);
+ }
/* Try to get a packet and process it. */
cc = (*rproc)(h, pkt, payload, tleft, rtype);
/* Return on data, EOF or real error. */
- if (cc != -1 || errno != 0)
+ if (cc != -1 || (errno != 0 && errno != ETIMEDOUT))
return (cc);
if ((getsecs() - t1) < tleft) {
goto recvnext;