summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1996-01-19 00:25:31 +0000
committerMiles Bader <miles@gnu.org>1996-01-19 00:25:31 +0000
commitc2f706d7e3143cbe2b57a0f3cf98e6ddcaefe32c (patch)
treeb5a050942736cc3a8136ed305cc0c1233d6772fa
parent662703fb4dceb5db343442f03aa1246e30e4490c (diff)
(trivfs_clean_protid):
Don't hold CRED->po->cntl->lock while calling TRIVFS_PEROPEN_DESTROY_HOOK.
-rw-r--r--libtrivfs/protid-clean.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/libtrivfs/protid-clean.c b/libtrivfs/protid-clean.c
index 42879c9e..b986fca0 100644
--- a/libtrivfs/protid-clean.c
+++ b/libtrivfs/protid-clean.c
@@ -29,11 +29,16 @@ trivfs_clean_protid (void *arg)
wasn't initialized to the point of needing user cleanup. */
(*trivfs_protid_destroy_hook) (cred);
+ /* If we hold the only reference to the peropen, try to get rid of it. */
mutex_lock (&cred->po->cntl->lock);
- if (!--cred->po->refcnt)
+ if (cred->po->refcnt == 1 && trivfs_peropen_destroy_hook)
+ {
+ mutex_unlock (&cred->po->cntl->lock);
+ (*trivfs_peropen_destroy_hook) (cred->po);
+ mutex_lock (&cred->po->cntl->lock);
+ }
+ if (--cred->po->refcnt == 0)
{
- if (trivfs_peropen_destroy_hook)
- (*trivfs_peropen_destroy_hook) (cred->po);
ports_port_deref (cred->po->cntl);
free (cred->po);
}