[lxc-devel] [lxc/lxc] b07511: utils: add macro __LXC_NUMSTRLEN

GitHub noreply at github.com
Tue Nov 29 03:24:58 UTC 2016


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

  Changed paths:
    M src/lxc/utils.h

  Log Message:
  -----------
  utils: add macro __LXC_NUMSTRLEN

This macro can be used to set or allocate a string buffer that can hold any
64bit representable number.

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


  Commit: c57dbb96588dbb8f79c40268a68fc38605e1f337
      https://github.com/lxc/lxc/commit/c57dbb96588dbb8f79c40268a68fc38605e1f337
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2016-11-28 (Mon, 28 Nov 2016)

  Changed paths:
    M src/lxc/log.c
    M src/lxc/log.h

  Log Message:
  -----------
  log: drop all timezone conversion functions

Our log functions need to make extra sure that they are thread-safe. We had
some problems with that before. This especially involves time-conversion
functions. I don't want to find any localtime() or gmtime() functions or
relatives in here. Not even localtime_r() or gmtime_r() or relatives. They all
fiddle with global variables and locking in various libcs. They cause deadlocks
when liblxc is used multi-threaded and no matter how smart you think you are,
you __will__ cause trouble using them.
(As a short example how this can cause trouble: LXD uses forkstart to fork off
a new process that runs the container. At the same time the go runtime LXD
relies on does its own multi-threading thing which we can't control. The
fork()ing + threading then seems to mess with the locking states in these time
functions causing deadlocks.)
The current solution is to be good old unix people and use the Epoch as our
reference point and simply use the seconds and nanoseconds that have past since
then. This relies on clock_gettime() which is explicitly marked MT-Safe with no
restrictions! This way, anyone who is really strongly invested in getting the
actual time the log entry was created, can just convert it for themselves. Our
logging is mostly done for debugging purposes so don't try to make it pretty.
Pretty might cost you thread-safety.

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


  Commit: 65a9df895ec25017cd822cb14a4b3077bdfe2401
      https://github.com/lxc/lxc/commit/65a9df895ec25017cd822cb14a4b3077bdfe2401
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2016-11-28 (Mon, 28 Nov 2016)

  Changed paths:
    M src/lxc/log.c

  Log Message:
  -----------
  log: add lxc_unix_epoch_to_utc()

Converts a unix time Epoch given by a struct timespec to a UTC string useable
in our logging functions. Maybe expanded to allow for more generic formatting.

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


  Commit: e1378d359105a50923691dabd038fbfbf4c6b91b
      https://github.com/lxc/lxc/commit/e1378d359105a50923691dabd038fbfbf4c6b91b
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2016-11-28 (Mon, 28 Nov 2016)

  Changed paths:
    M src/lxc/log.c

  Log Message:
  -----------
  log: use lxc_unix_epoch_to_utc()

This allows us to generate nice timestamps in a thread-safe manner without
relying on locale touching functions from any libc.

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


  Commit: d86c0d08c4f9a3e11fddf401a9d46372a8aa085d
      https://github.com/lxc/lxc/commit/d86c0d08c4f9a3e11fddf401a9d46372a8aa085d
  Author: Christian Brauner <christian.brauner at ubuntu.com>
  Date:   2016-11-29 (Tue, 29 Nov 2016)

  Changed paths:
    M src/lxc/log.c

  Log Message:
  -----------
  log: annotate lxc_unix_epoch_to_utc()

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


  Commit: 258e3e43a87d5beafce04e83cd4534b7937e1d43
      https://github.com/lxc/lxc/commit/258e3e43a87d5beafce04e83cd4534b7937e1d43
  Author: Serge Hallyn <serge at hallyn.com>
  Date:   2016-11-28 (Mon, 28 Nov 2016)

  Changed paths:
    M src/lxc/log.c
    M src/lxc/log.h
    M src/lxc/utils.h

  Log Message:
  -----------
  Merge pull request #1331 from brauner/2016-11-27/use_sec_nanosec_since_epoch

log: drop all timezone conversion functions


Compare: https://github.com/lxc/lxc/compare/1fbb7fae5238...258e3e43a87d


More information about the lxc-devel mailing list