aboutsummaryrefslogtreecommitdiffstats
path: root/src/svm
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2021-01-20 19:10:59 +0100
committerFlorin Coras <florin.coras@gmail.com>2021-01-24 02:36:16 +0000
commit78de92de0ddb5de67ceb70bd30ff6dfae345baf1 (patch)
tree6a80cee7946065816fcf040befc71a866271daa3 /src/svm
parent2e4523816ca0e366a4f597a0e5fdb93fccc887a5 (diff)
svm: use standard function to reset stale mutex
Avoid accessing the private data structure of mutexes which is implementation-dependent, eg. musl is different from glibc. Type: improvement Change-Id: I20ec0c1c9faef0749d89a1969cd2430c80ac04b3 Signed-off-by: Benoît Ganne <bganne@cisco.com>
Diffstat (limited to 'src/svm')
-rw-r--r--src/svm/svm.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/svm/svm.c b/src/svm/svm.c
index 2834524b934..313fe4a8787 100644
--- a/src/svm/svm.c
+++ b/src/svm/svm.c
@@ -716,12 +716,17 @@ svm_map_region (svm_map_region_args_t * a)
pid_holding_region_lock = rp->mutex_owner_pid;
if (pid_holding_region_lock && kill (pid_holding_region_lock, 0) < 0)
{
+ pthread_mutexattr_t attr;
clib_warning
("region %s mutex held by dead pid %d, tag %d, force unlock",
rp->region_name, pid_holding_region_lock, rp->mutex_owner_tag);
/* owner pid is nonexistent */
- rp->mutex.__data.__owner = 0;
- rp->mutex.__data.__lock = 0;
+ if (pthread_mutexattr_init (&attr))
+ clib_unix_warning ("mutexattr_init");
+ if (pthread_mutexattr_setpshared (&attr, PTHREAD_PROCESS_SHARED))
+ clib_unix_warning ("mutexattr_setpshared");
+ if (pthread_mutex_init (&rp->mutex, &attr))
+ clib_unix_warning ("mutex_init");
dead_region_recovery = 1;
}