[lxc-devel] [lxc/lxc] 6a22e8: configure: check whether gettid() is declared

GitHub noreply at github.com
Fri Nov 25 23:20:26 UTC 2016


  Branch: refs/heads/master
  Home:   https://github.com/lxc/lxc
  Commit: 6a22e862589c9d3e42d2d79fdf7e73a62b8145bd
      https://github.com/lxc/lxc/commit/6a22e862589c9d3e42d2d79fdf7e73a62b8145bd
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2016-11-25 (Fri, 25 Nov 2016)

  Changed paths:
    M configure.ac
    M src/lxc/log.c

  Log Message:
  -----------
  configure: check whether gettid() is declared

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>


  Commit: 0dcdbf8a67534897275795edddd5550993ecc003
      https://github.com/lxc/lxc/commit/0dcdbf8a67534897275795edddd5550993ecc003
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2016-11-25 (Fri, 25 Nov 2016)

  Changed paths:
    M src/lxc/log.c

  Log Message:
  -----------
  log: fix race

localtime_r() can lead to deadlocks because it calls __tzset() and
__tzconvert() internally. The deadlock stems from an interaction between these
functions and the functions in monitor.c and commands.{c,h}. The latter
functions will write to the log independent of the container thread that is
currently running. Since the monitor fork()ed it seems to duplicate the mutex
states of the time functions mentioned above causing the deadlock.
As a short termm fix, I suggest to simply disable receiving the time when
monitor.c or command.{c,h} functions are called. This should be ok, since the
[lxc monitor] will only emit a few messages and thread-safety is currently more
important than beautiful logs. The rest of the log stays the same as it was
before.

Here is an example output from logs where I printed the pid and tid of the
process that is currently writing to the log:
       lxc 20161125170200.619 INFO     lxc_start:   18695-18695: - start.c:lxc_check_inherited:243 - Closed inherited fd: 23.
      lxc 20161125170200.640 DEBUG    lxc_start:   18677-18677: - start.c:__lxc_start:1334 - Not dropping CAP_SYS_BOOT or watching utmp.
      lxc 20161125170200.640 INFO     lxc_cgroup:  18677-18677: - cgroups/cgroup.c:cgroup_init:68 - cgroup driver cgroupfs-ng initing for lxc-test-concurrent-0

----------> lxc 20150427012246.000 INFO     lxc_monitor: 13017-18622: - monitor.c:lxc_monitor_sock_name:178 - using monitor sock name lxc/ad055575fe28ddd5//var/lib/lxc
       lxc 20161125170200.662 DEBUG    lxc_cgfsng:  18677-18677: - cgroups/cgfsng.c:filter_and_set_cpus:478 - No isolated cpus detected.
      lxc 20161125170200.662 DEBUG    lxc_cgfsng:  18677-18677: - cgroups/cgfsng.c:handle_cpuset_hierarchy:648 - "cgroup.clone_children" was already set to "1".

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>


  Commit: 450b6d3d684000762dab8817825feb6da55b08f4
      https://github.com/lxc/lxc/commit/450b6d3d684000762dab8817825feb6da55b08f4
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2016-11-25 (Fri, 25 Nov 2016)

  Changed paths:
    M src/lxc/log.c

  Log Message:
  -----------
  log: use N/A if getpid() != gettid() when threaded

Sample log output:

    lxc 20161125201943.819 INFO     lxc_start - start.c:lxc_check_inherited:243 - Closed inherited fd: 54.
--> lxc N/A                INFO     lxc_monitor - monitor.c:lxc_monitor_sock_name:178 - using monitor sock name lxc/ad055575fe28ddd5//var/lib/lxc
    lxc 20161125201943.958 DEBUG    lxc_commands - commands.c:lxc_cmd_handler:893 - peer has disconnected
--> lxc N/A                DEBUG    lxc_commands - commands.c:lxc_cmd_get_state:579 - 'lxc-test-concurrent-0' is in 'RUNNING' state
    lxc 20161125201943.960 DEBUG    lxc_commands - commands.c:lxc_cmd_handler:893 - peer has disconnected
    lxc 20161125201944.009 INFO     lxc_start - start.c:lxc_check_inherited:243 - Closed inherited fd: 3.

Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>


  Commit: 1145b82876ab9690dccc4a9a62d049cd4166e608
      https://github.com/lxc/lxc/commit/1145b82876ab9690dccc4a9a62d049cd4166e608
  Author: Stéphane Graber <stgraber at stgraber.org>
  Date:   2016-11-25 (Fri, 25 Nov 2016)

  Changed paths:
    M configure.ac
    M src/lxc/log.c

  Log Message:
  -----------
  Merge pull request #1319 from brauner/2016-11-25/fix_logging_race

log: fix race


Compare: https://github.com/lxc/lxc/compare/8d3786cb7539...1145b82876ab


More information about the lxc-devel mailing list