Commit Graph

5 Commits

Author SHA1 Message Date
Danny Al-Gaaf
39ffec281a misc: mark constructors as explicit
Set 218 constructors as explicit to avoid implicit usage.

Fix for cppcheck warning:
 Class has a constructor with 1 argument that is
 not explicit. Such constructors should in general be explicit for
 type safety reasons. Using the explicit keyword in the constructor
 means some mistakes when using the class can be avoided.

 For more information check:
  https://www.codeproject.com/Articles/28663/Explicit-Constructor-in-C

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
2018-05-02 17:01:58 +02:00
John Spray
625e1b5cfb mgr: safety checks on pyThreadState usage
Previously relied on the caller of Gil() to
pass new_thread=true if they would be
calling from a different thread.

Enforce this with an assertion, by wrapping
PyThreadState in a SafeThreadState class
that remembers which POSIX thread
it's meant to be used in.

Signed-off-by: John Spray <john.spray@redhat.com>
2017-10-16 07:06:23 -04:00
John Spray
23c3a075ee mgr: move Gil implementation into .cc
The inclusion of Python.h in the .h was awkward
for other files including Gil.h.

Signed-off-by: John Spray <john.spray@redhat.com>
2017-10-16 07:06:23 -04:00
John Spray
987612a975 mgr: reduce Gil verbosity at level 20
Even at 20, it's pretty heavy to be logging
every lock acquire/release.

Signed-off-by: John Spray <john.spray@redhat.com>
2017-10-16 07:06:22 -04:00
Tim Serong
f36b0d9d40 mgr: use new Gil class in place of PyGILState_*() API
Prep work for loading modules in separate python sub-interpreters.
According to the Python C API docs, mixing the PyGILState_*() API
with sub-interpreters is unsupported, so I've replaced these calls
with a Gil class, which will acquire and release the GIL against
a specific python thread state.

Note the manual python thread state creation in MgrPyModule::serve().
The PyGILState_*() APIs would have done that for us, but we're not
using them anymore, so have to do it by hand (see
https://docs.python.org/2/c-api/init.html#non-python-created-threads
for some description of this).

Signed-off-by: Tim Serong <tserong@suse.com>
2017-05-22 16:52:48 +10:00