summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2018-01-06 02:05:06 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2018-01-06 02:05:06 +0100
commit6868c17b7def25beb69e7b685496e078340d8b12 (patch)
tree8b46e160460b3975a6d299fd7b2fc209e8cfe525
parentc4cb76bb13d01eaa93ee77ba5b490f5d1a991155 (diff)
libfshelp/get-identity.c: Simplify checking weak references
* libfshelp/get-identity.c (id_clean): Test whether i is still in the hash table instead of counting weak references.
-rw-r--r--libfshelp/get-identity.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/libfshelp/get-identity.c b/libfshelp/get-identity.c
index 96de55a8..ac1b4f0b 100644
--- a/libfshelp/get-identity.c
+++ b/libfshelp/get-identity.c
@@ -69,14 +69,13 @@ static void
id_clean (void *cookie)
{
struct idspec *i = cookie;
- struct references result;
pthread_mutex_lock (&idlock);
- refcounts_references (&i->pi.refcounts, &result);
- if (result.hard == 0 && result.weak == 2)
+ if (refcounts_hard_references(&i->pi.refcounts) == 0
+ && i->id_hashloc != NULL)
{
- /* Nobody got a send right in between and we have the last weak reference
- in addition to our caller's, so we can remove from the hash. */
+ /* Nobody got a send right in between, we can remove i from the hash. */
hurd_ihash_locp_remove (&idhash, i->id_hashloc);
+ i->id_hashloc = NULL;
ports_port_deref_weak (&i->pi);
}
pthread_mutex_unlock (&idlock);