loader: ip: Do not call getsecs so much

getsecs is very costly, reuse the values we got before.

Fetching a ~30MB kernel with the tftp command use to take ~26 seconds
and now it's ~18 seconds.

Reviewed by:	imp, tsoome
MFC after:	2 weeks
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D33408
This commit is contained in:
Emmanuel Vadot 2021-12-09 15:46:39 +01:00
parent 4f36ed513c
commit c5f24f5e0d

View File

@ -101,10 +101,9 @@ sendrecv(struct iodesc *d,
tmo = MINTMO;
tlast = 0;
tleft = 0;
tref = getsecs();
t = getsecs();
tref = t = getsecs();
for (;;) {
if (MAXWAIT > 0 && (getsecs() - tref) >= MAXWAIT) {
if (MAXWAIT > 0 && (t - tref) >= MAXWAIT) {
errno = ETIMEDOUT;
return -1;
}