[lxc-devel] [PATCH 1/2] Remove process_lock() except where actually needed

Andrey Mazo mazo at telum.ru
Wed Dec 25 11:10:33 UTC 2013


On Tue, 24 Dec 2013 19:05:14 +0400, Serge Hallyn <serge.hallyn at ubuntu.com> wrote:
[snip]
> And so while I don't like doing so, it sounds like it would be worth
> wrapping all calls to fork() within the API with a version that
> frees the process (and static, while it exists) lock(s).  Because
> unlike lxc_fopen(), this would be needed for all libcs and in
> perpetuity.  (Ideally we'd be able to do it through linker magic
> without having to write a wrapper;  else we must have a make rule
> that kindly warns developers to use lxc_fork() unless a file is
> tagged as single-threaded).
>
> That's just a thought for a future patch, not a request for this patch!

I agree, that this is worth doing as remembering to put process_unlock() after each fork() is quite tedious.
Linker-based approach should work.
As far as I can see, the second approach could be implemented either via grepping source file for fork() in Makefile or just defining a macro fork() to cause a compilation error (though these errors may be quite cryptic).

[snip]

>> Signed-off-by: Andrey Mazo <mazo at telum.ru>
>
> Thanks very much, Andrey.
>
> Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>

Thank you for reviewing the patchset!
Also great thanks to S.Çağlar Onur for his testing and detection of openpty() problem!

>> ---
>>  src/lxc/af_unix.c      |  17 ---------
>>  src/lxc/attach.c       |  32 ----------------
>>  src/lxc/bdev.c         |  58 +---------------------------
>>  src/lxc/caps.c         |   5 ---
>>  src/lxc/cgroup.c       |  35 -----------------
>>  src/lxc/commands.c     |  11 ------
>>  src/lxc/conf.c         |  70 ----------------------------------
>>  src/lxc/console.c      |  18 ---------
>>  src/lxc/freezer.c      |   5 ---
>>  src/lxc/log.c          |   7 ----
>>  src/lxc/lsm/apparmor.c |  11 ------
>>  src/lxc/lxccontainer.c | 101 -------------------------------------------------
>>  src/lxc/lxclock.c      |   9 -----
>>  src/lxc/lxcutmp.c      |  11 ------
>>  src/lxc/mainloop.c     |  11 +-----
>>  src/lxc/monitor.c      |  19 +---------
>>  src/lxc/network.c      |  20 +---------
>>  src/lxc/nl.c           |   5 ---
>>  src/lxc/parse.c        |   5 ---
>>  src/lxc/seccomp.c      |   5 ---
>>  src/lxc/start.c        |  29 --------------
>>  src/lxc/state.c        |   5 ---
>>  src/lxc/sync.c         |   7 ----
>>  src/lxc/utils.c        |  47 +++--------------------
>>  src/lxc/utils.h        |   2 -
>>  25 files changed, 10 insertions(+), 535 deletions(-)

-- 
Andrey Mazo.


More information about the lxc-devel mailing list