Index: hurd-debian/libfshelp/get-identity.c =================================================================== --- hurd-debian.orig/libfshelp/get-identity.c +++ hurd-debian/libfshelp/get-identity.c @@ -42,7 +43,12 @@ id_clean (void *cookie) { struct idspec *i = cookie; pthread_mutex_lock (&idlock); - hurd_ihash_locp_remove (&idhash, i->id_hashloc); + if (refcounts_hard_references(&i->pi.refcounts) == 0) + { + /* Nobody got a send right in between, we can remove from the hash. */ + hurd_ihash_locp_remove (&idhash, i->id_hashloc); + ports_port_deref_weak (&i->pi); + } pthread_mutex_unlock (&idlock); } @@ -50,7 +56,7 @@ static void id_initialize () { assert_backtrace (!idclass); - idclass = ports_create_class (id_clean, NULL); + idclass = ports_create_class (NULL, id_clean); } error_t @@ -75,6 +81,9 @@ fshelp_get_identity (struct port_bucket if (err) goto lose_port; + /* Weak reference for the hash entry. */ + ports_port_ref_weak(&i->pi); + *pt = ports_get_right (i); ports_port_deref (i); }