Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Alex Xu <alex_y_xu@yahoo.ca>
Cc: netfilter@vger.kernel.org, netfilter-devel@vger.kernel.org,
	eric@regit.org
Subject: Re: ulogd's SQLITE3 "buffer" option
Date: Wed, 30 Dec 2015 01:19:05 +0100	[thread overview]
Message-ID: <20151230001905.GA1700@salvia> (raw)
In-Reply-To: <20151229183831.0ff29890@alex-desktop>

On Tue, Dec 29, 2015 at 06:38:31PM -0500, Alex Xu wrote:
> I was attempting to configure sqlite3 output in ulogd and could not
> determine the function of the "buffer" configuration option.
> 
> $ grep buffer output/sqlite3/ulogd_output_sqlite3.c
>         int buffer_size;
>         int buffer_curr;
>                         .key = "buffer",
> #define buffer_ce(pi)   (pi)->config_kset->ces[2].u.value
>                 priv->buffer_curr++;
>         /* initialize our buffer size and counter */
>         priv->buffer_size = buffer_ce(pi);
>         priv->buffer_curr = 0;
> $ grep -rF buffer_curr .
> output/sqlite3/ulogd_output_SQLITE3.c:  int buffer_curr;
> output/sqlite3/ulogd_output_SQLITE3.c:          priv->buffer_curr++;
> output/sqlite3/ulogd_output_SQLITE3.c:  priv->buffer_curr = 0;
> 
> Now, it is quite likely that I am missing something, but it would
> appear that buffer_curr is never actually *read*, only *written*,
> and it's a basic fact of programming that a variable can have no effect
> if it is never read from. [citation needed]
> 
> It would appear that the original code in ulogd-1.x employed a 'buffer'
> which was actually a counter for when to tell sqlite to sync to disk.
> When the code was rewritten by "Holger" and committed by Pablo Neira
> Ayuso (8f7bb61), the syncing part was removed but the buffer variable
> was simply renamed.
> 
> Nobody noticed because one fsync every few seconds is tiny.
> 
> Therefore, I think we should remove the "buffer" option entirely.
> 
> Thoughts? I will send a patch if there are no objections.

This may be well a leftover that was introduced by when that large
rewrite took, please submit a patch that we can review.

I'm also Cc'ing Eric Leblond, he maintains ulogd2, just in case he
finds some cycles to confirm this issue.

Thanks for reporting.

  reply	other threads:[~2015-12-30  0:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-29 23:38 ulogd's SQLITE3 "buffer" option Alex Xu
2015-12-30  0:19 ` Pablo Neira Ayuso [this message]
2016-01-01 10:04   ` Eric Leblond

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=20151230001905.GA1700@salvia \
    --to=pablo@netfilter.org \
    --cc=alex_y_xu@yahoo.ca \
    --cc=eric@regit.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=netfilter@vger.kernel.org \
    /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