Fix a bug caused by the fact that the shared_mutex is not recursive