[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZbN5uAeqEKJth5Jv@Laptop-X1>
Date: Fri, 26 Jan 2024 17:22:00 +0800
From: Hangbin Liu <liuhangbin@...il.com>
To: Przemek Kitszel <przemyslaw.kitszel@...el.com>
Cc: netdev@...r.kernel.org, Jay Vosburgh <j.vosburgh@...il.com>,
"David S . Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Eric Dumazet <edumazet@...gle.com>, Liang Li <liali@...hat.com>
Subject: Re: [PATCH net-next 1/4] selftests/net/forwarding: add slowwait
functions
Hi Przemek,
Thanks for your review.
On Wed, Jan 24, 2024 at 02:25:57PM +0100, Przemek Kitszel wrote:
> > +# timeout in seconds
> > +slowwait()
> > +{
> > + local timeout=$1; shift
> > +
> > + local start_time="$(date -u +%s)"
> > + while true
> > + do
> > + local out
> > + out=$("$@")
> > + local ret=$?
> > + if ((!ret)); then
>
> it would be nice to have some exit code used (or just reserved) for
> "operation failed, no need to wait, fail the test please"
> similar to the xargs, eg:
> 126 if the command cannot be run
Return directly instead of wait may confuse the caller. Maybe we can
add a parameter and let user decide whether to wait if return some value.
e.g.
slowwait nowait 126 $timeout $commands
>
> > + echo -n "$out"
> > + return 0
> > + fi
> > +
> > + local current_time="$(date -u +%s)"
> > + if ((current_time - start_time > timeout)); then
> > + echo -n "$out"
> > + return 1
> > + fi
> > +
> > + sleep 1
>
> I see that `sleep 1` is simplest correct impl, but it's tempting to
> suggest exponential back-off, perhaps with saturation at 15
>
> (but then you will have to cap last sleep to don't exceed timeout by
> more than 1).
Do you mean sleep longer when cmd exec failed? I'm not sure if it's a good
idea as the caller still wants to return ASAP when cmd exec succeeds.
Thanks
Hangbin
Powered by blists - more mailing lists