]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
mgr/ActivePyModule: avoid with_gil where possible 44207/head
authorSage Weil <sage@newdream.net>
Wed, 24 Nov 2021 17:02:05 +0000 (12:02 -0500)
committerSage Weil <sage@newdream.net>
Wed, 24 Nov 2021 18:05:14 +0000 (13:05 -0500)
commit6469a9a6a14ef388d1bf486355af78c301086232
treeaa118bed1d87f93d8c41a99d1b6595feaf008ade
parent1da9885e4ec3e0f9ebad3159cd68da31b0ec7602
mgr/ActivePyModule: avoid with_gil where possible

The common pattern of

 without_gil_t no_gil;
 ...
 with_gil_t with_gil(no_gil);
 ...

is that when the stack unwindws, ~with_gil_t() will drop the GIL and then
~without_gil_t() will retake it again, adding a completely unnecessary
unlock/lock cycle.

Instead, do

 no_gil.acquire_gil();

when we are ready to retake the GIL.  ~without_gil_t() will then be a
no-op.

Signed-off-by: Sage Weil <sage@newdream.net>
src/mgr/ActivePyModules.cc
src/mgr/Gil.h