[lxc-devel] [lxc/lxc] 9c88ff: Eliminate duplicate entries from list_active_conta...

GitHub noreply at github.com
Fri Oct 25 23:18:09 UTC 2013


  Branch: refs/heads/master
  Home:   https://github.com/lxc/lxc
  Commit: 9c88ff1f95eea1e1b2c06c22fcc09c5cb94bd270
      https://github.com/lxc/lxc/commit/9c88ff1f95eea1e1b2c06c22fcc09c5cb94bd270
  Author: S.Çağlar Onur <caglar at 10ur.org>
  Date:   2013-10-25 (Fri, 25 Oct 2013)

  Changed paths:
    M src/lxc/lxccontainer.c

  Log Message:
  -----------
  Eliminate duplicate entries from list_active_containers (v2)

list_active_containers parses /proc/net/unix which can contain multiple entries for the same container;

0000000000000000: 00000002 00000000 00010000 0001 01 273672 @/var/lib/lxc/6/command
0000000000000000: 00000002 00000000 00010000 0001 01 274395 @/var/lib/lxc/5/command
0000000000000000: 00000002 00000000 00010000 0001 01 273890 @/var/lib/lxc/4/command
0000000000000000: 00000002 00000000 00010000 0001 01 273141 @/var/lib/lxc/3/command
0000000000000000: 00000002 00000000 00010000 0001 01 273915 @/var/lib/lxc/2/command
0000000000000000: 00000002 00000000 00010000 0001 01 273683 @/var/lib/lxc/1/command
0000000000000000: 00000002 00000000 00010000 0001 01 273074 @/var/lib/lxc/0/command
0000000000000000: 00000002 00000000 00010000 0001 01 273931 @/var/lib/lxc/9/command
0000000000000000: 00000002 00000000 00010000 0001 01 273110 @/var/lib/lxc/8/command
0000000000000000: 00000002 00000000 00010000 0001 01 273390 @/var/lib/lxc/7/command
0000000000000000: 00000003 00000000 00000000 0001 03 275903 @/var/lib/lxc/8/command
0000000000000000: 00000003 00000000 00000000 0001 03 276043 @/var/lib/lxc/1/command
0000000000000000: 00000003 00000000 00000000 0001 03 273301 @/var/lib/lxc/0/command
0000000000000000: 00000003 00000000 00000000 0001 03 275650 @/var/lib/lxc/4/command

On this system list_active_containers returns 14 containers while only 10 containers are running.

Following patch;

	* Introduces array_contains function to do a binary search on given array,
	* Starts to sort arrays inside the add_to_clist and add_to_names functions,
	* Consumes array_contains in list_active_containers to eliminate duplicates,
	* Replaces the linear search code in lxcapi_get_interfaces with the new function.

Changes since v1:
	* Do not load containers if a if a container list is not passed in
	* Fix possible memory leaks in lxcapi_get_ips and lxcapi_get_interfaces if realloc fails

Signed-off-by: S.Çağlar Onur <caglar at 10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>


  Commit: aae93dd3dd20dd12c6b8f9f0490e2fb877ee3f09
      https://github.com/lxc/lxc/commit/aae93dd3dd20dd12c6b8f9f0490e2fb877ee3f09
  Author: S.Çağlar Onur <caglar at 10ur.org>
  Date:   2013-10-25 (Fri, 25 Oct 2013)

  Changed paths:
    M src/lxc/af_unix.c
    M src/lxc/af_unix.h
    M src/lxc/commands.c
    M src/lxc/lxc_monitord.c
    M src/lxc/monitor.c

  Log Message:
  -----------
  Use actual length of socket's name for abstract sockets (v3)

The addrlen parameter should be the actual length of socket's name for abstract sockets. Otherwise socket gets padded with NULLs.

cat /proc/net/unix | grep lxc
[...]
0000000000000000: 00000003 00000000 00000000 0001 03 226548 @lxc/ad055575fe28ddd5//var/lib/lxc^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
[...]

with this patch;

cat /proc/net/unix | grep lxc
[...]
0000000000000000: 00000002 00000000 00010000 0001 01 109563 @lxc/ad055575fe28ddd5//var/lib/lxc
[...]

Changes since v1:
    * check the length of passed-in string
Changes since v2:
    * remove non-abstract socket code path to simplify functions
    * rename lxc_af_unix_* family to lxc_abstract_unix_*

Signed-off-by: S.Çağlar Onur <caglar at 10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>


Compare: https://github.com/lxc/lxc/compare/44f820e30b6f...aae93dd3dd20


More information about the lxc-devel mailing list