Util-Linux package development
 help / color / mirror / Atom feed
From: Karel Zak <kzak@redhat.com>
To: Sami Kerola <kerolasa@iki.fi>
Cc: util-linux@vger.kernel.org
Subject: Re: [PATCH 03/16] flock: improve timeout handling
Date: Tue, 24 Feb 2015 11:21:28 +0100	[thread overview]
Message-ID: <20150224102128.GF19430@ws.net.home> (raw)
In-Reply-To: <1424616106-580-4-git-send-email-kerolasa@iki.fi>

On Sun, Feb 22, 2015 at 02:41:33PM +0000, Sami Kerola wrote:
> Signal ALRM raised by the timer, and the timer only, will be considered
> as a timeout criteria.
> 
> Secondly time interval is made to use monotonic clock.  Documentation of
> ITIMER_REAL is unclear whether that time is affected various sources of
> clock skew, or does it even tick when system is suspended.

I agree, setitimer() API is also obsolete.

> This code is moved from libcommon.la to flock.c because of two reasons.
> This is the only utility using the function, and setup_timer() along with
> cancel_timer() need to be linked with -lrt option.

Hmm... yes, it's used by flock only, but I still think it would be
better to keep it in common lib/ code. Maybe we can use the timers on
another places later (uuidd, login, sulogin, ...).

What about to keep all -lrt stuff in lib/monotonic.c?

> --- a/sys-utils/Makemodule.am
> +++ b/sys-utils/Makemodule.am
> @@ -2,7 +2,7 @@ if BUILD_FLOCK
>  usrbin_exec_PROGRAMS += flock
>  dist_man_MANS += sys-utils/flock.1
>  flock_SOURCES = sys-utils/flock.c lib/monotonic.c
> -flock_LDADD = $(LDADD) libcommon.la $(CLOCKGETTIME_LIBS)
> +flock_LDADD = $(LDADD) libcommon.la -lrt

Don't use -l<foo> in Makefiles, always use $(FOO) and initialize the
variable in ./configure, $(CLOCKGETTIME_LIBS) is fine (although the
name of the variable is not perfect in this context).

> +static void timeout_handler(int sig __attribute__((__unused__)),
> +			    siginfo_t *info,
> +			    void *context __attribute__((__unused__)))
>  {
> -	timeout_expired = 1;
> +	if (info->si_code == SI_TIMER)
> +		timeout_expired = 1;
>  }

BTW, it mean that "kill -ALRM" does not force the program to set 
timeout_expired, right? Nice.

> +static int setup_timer(timer_t *t_id, struct itimerval *timeout)

if you move it to lib/ than add a pointer to timeout_handler() too

Anyway, it seems more elegant than the previous implementation.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

  reply	other threads:[~2015-02-24 10:21 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-22 14:41 [PATCH 00/16] pull: changes to various utils Sami Kerola
2015-02-22 14:41 ` [PATCH 01/16] whereis: tell when mandatory option is missing Sami Kerola
2015-02-22 17:37   ` Benno Schulenberg
2015-02-24  9:40   ` Karel Zak
2015-03-01 11:08     ` Sami Kerola
2015-03-03 11:32       ` Karel Zak
2015-03-03 12:59         ` Sami Kerola
2015-03-03 23:07           ` Sami Kerola
2015-02-22 14:41 ` [PATCH 02/16] flock: add --verbose option Sami Kerola
2015-02-22 17:44   ` Benno Schulenberg
2015-03-01 11:11     ` Sami Kerola
2015-02-22 14:41 ` [PATCH 03/16] flock: improve timeout handling Sami Kerola
2015-02-24 10:21   ` Karel Zak [this message]
2015-03-01 11:46     ` Sami Kerola
2015-03-02  9:13       ` Karel Zak
2015-03-05  9:36   ` Karel Zak
2015-02-22 14:41 ` [PATCH 04/16] prlimit: tell in --verbose output which pid got the new limit Sami Kerola
2015-02-24 10:25   ` Karel Zak
2015-02-22 14:41 ` [PATCH 05/16] tunelp: remove get_val() in favour of strtol_or_err() Sami Kerola
2015-02-24 10:29   ` Karel Zak
2015-02-22 14:41 ` [PATCH 06/16] tunelp: remove unnecessary preprocessor directives Sami Kerola
2015-02-22 14:41 ` [PATCH 07/16] lib/strutils: move parse_switch() from setterm(1) to library Sami Kerola
2015-02-22 17:12   ` Benno Schulenberg
2015-02-24 10:34   ` Karel Zak
2015-02-22 14:41 ` [PATCH 08/16] tunelp: use parse_switch() Sami Kerola
2015-02-24 10:40   ` Karel Zak
2015-02-22 14:41 ` [PATCH 09/16] eject: " Sami Kerola
2015-02-24 11:37   ` Karel Zak
2015-03-01 11:49     ` Sami Kerola
2015-02-22 14:41 ` [PATCH 10/16] rpmatch: use symbolic value when evaluation return codes Sami Kerola
2015-02-24 11:47   ` Karel Zak
2015-02-22 14:41 ` [PATCH 11/16] tailf: check printing criteria more carefully Sami Kerola
2015-02-24 11:53   ` Karel Zak
2015-03-01 11:55     ` Sami Kerola
2015-02-22 14:41 ` [PATCH 12/16] tailf: count last lines correctly at initial print out Sami Kerola
2015-02-24 12:12   ` Karel Zak
2015-03-01 12:09     ` Sami Kerola
2015-02-22 14:41 ` [PATCH 13/16] tailf: do not allow minus signed last lines argument Sami Kerola
2015-02-22 14:41 ` [PATCH 14/16] tailf: ensure file argument really is a file Sami Kerola
2015-02-24 12:18   ` Karel Zak
2015-03-01 12:20     ` Sami Kerola
2015-02-22 14:41 ` [PATCH 15/16] logger: move /dev/log to pathnames.h Sami Kerola
2015-02-24 12:19   ` Karel Zak
2015-02-22 14:41 ` [PATCH 16/16] logger: fix -i argument parsing regression Sami Kerola
2015-02-22 17:21   ` Benno Schulenberg
2015-03-01 11:06     ` Sami Kerola
2015-02-22 17:10 ` [PATCH 11/62] pull: Benno Schulenberg
2015-03-05 10:16 ` [PATCH 00/16] pull: changes to various utils Karel Zak

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=20150224102128.GF19430@ws.net.home \
    --to=kzak@redhat.com \
    --cc=kerolasa@iki.fi \
    --cc=util-linux@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