2 * See the file LICENSE for redistribution information.
4 * Copyright (c) 2005-2009 Oracle. All rights reserved.
15 * Check for mutexes held by dead processes.
17 * PUBLIC: int __mut_failchk __P((ENV *));
26 DB_MUTEXREGION *mtxregion;
29 char buf[DB_THREADID_STRLEN];
32 mtxmgr = env->mutex_handle;
33 mtxregion = mtxmgr->reginfo.primary;
36 MUTEX_SYSTEM_LOCK(env);
37 for (i = 1; i <= mtxregion->stat.st_mutex_cnt; ++i, ++mutexp) {
38 mutexp = MUTEXP_SET(mtxmgr, i);
41 * We're looking for per-process mutexes where the process
44 if (!F_ISSET(mutexp, DB_MUTEX_ALLOCATED) ||
45 !F_ISSET(mutexp, DB_MUTEX_PROCESS_ONLY))
49 * The thread that allocated the mutex may have exited, but
50 * we cannot reclaim the mutex if the process is still alive.
53 dbenv, mutexp->pid, 0, DB_MUTEX_PROCESS_ONLY))
56 __db_msg(env, "Freeing mutex for process: %s",
57 dbenv->thread_id_string(dbenv, mutexp->pid, 0, buf));
59 /* Unlock and free the mutex. */
60 if (F_ISSET(mutexp, DB_MUTEX_LOCKED))
63 if ((ret = __mutex_free_int(env, 0, &i)) != 0)
66 MUTEX_SYSTEM_UNLOCK(env);