From: Pablo Neira Ayuso <pablo@netfilter.org>
To: subashab@codeaurora.org
Cc: netfilter-devel@vger.kernel.org, Liping Zhang <zlpnobody@gmail.com>
Subject: Re: [PATCH v2] xtables: Add a smaller delay option when waiting for xtables lock
Date: Fri, 20 May 2016 12:14:46 +0200 [thread overview]
Message-ID: <20160520101446.GA8771@salvia> (raw)
In-Reply-To: <736e561105702835e5cedea5e3ed18b7@codeaurora.org>
On Tue, May 17, 2016 at 12:25:53PM -0600, subashab@codeaurora.org wrote:
> >>iptables -w 2.1
> >>
> >>0.01s sleep, retry
> >>0.02s sleep, retry
> >>0.03s sleep, retry
> >>...
> >>2.1s sleep, exit
> >>
> >>Note that it sleeps for 10ms and retries rather than sleeping for a
> >>single
> >>iteration for 2.1s seconds and then retrying.
> >>
> >>Let me know if there are any concerns with this.
> >
> >But this is changing the existing behaviour, right? My understanding
> >is that -w indicates the net wait time for each try.
>
> Hi Pablo
>
> Currently, each wait time is 1 second. -w is the overall time upto which it
> has to wait.
>
> bool xtables_lock(int wait)
> {
> int fd, waited = 0, i = 0;
>
> fd = open(XT_LOCK_NAME, O_CREAT, 0600);
> if (fd < 0)
> return true;
>
> while (1) {
> if (flock(fd, LOCK_EX | LOCK_NB) == 0)
> return true;
> else if (wait >= 0 && waited >= wait) //total time upto which we need to
> wait.
> return false;
> if (++i % 2 == 0)
> fprintf(stderr, "Another app is currently holding the xtables lock; "
> "waiting (%ds) for it to exit...\n", waited);
> waited++;
> sleep(1); //sleep for one second only
> }
> }
>
> My patch does not change the behavior of -w itself. It only changes the
> sleep interval to 10ms when a decimal is specified.
Sorry, then I misunderstood the semantics of -w, I remembered this
specified the sleep interval but I was wrong.
> Existing behavior of 1 second sleep for integral interval is preserved.
Then, I'd suggest you add a new specific option to specify the
interval, allowing this sec.msecs notation, preserving the 1 second
interval as default.
Thanks.
prev parent reply other threads:[~2016-05-20 10:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-06 3:18 [PATCH v2] xtables: Add a smaller delay option when waiting for xtables lock Subash Abhinov Kasiviswanathan
2016-05-09 21:40 ` Pablo Neira Ayuso
2016-05-17 3:30 ` subashab
2016-05-17 10:41 ` Pablo Neira Ayuso
2016-05-17 18:25 ` subashab
2016-05-19 22:06 ` subashab
2016-05-20 10:14 ` Pablo Neira Ayuso [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160520101446.GA8771@salvia \
--to=pablo@netfilter.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=subashab@codeaurora.org \
--cc=zlpnobody@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).