[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 04/16: libfshelp: Add weak reference for hash table reference
From: |
Samuel Thibault |
Subject: |
[hurd] 04/16: libfshelp: Add weak reference for hash table reference |
Date: |
Tue, 09 Jan 2018 01:35:29 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit b37c7dd4dd0de064b7ae2c9ad5687ebb635677c8
Author: Samuel Thibault <address@hidden>
Date: Tue Dec 19 01:39:36 2017 +0100
libfshelp: Add weak reference for hash table reference
Fixes reference w/o send right crash.
* libfshelp/get-identity.c (fshelp_get_identity): Get weak reference for
the hash table reference.
(id_initialize): Pass id_clean as dropweak_routine instead of
clean_routine to ports_create_class.
(id_clean): Remove from hash table only if there are no hard references
left, i.e. we didn't reacquired a port right in between.
---
libfshelp/get-identity.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/libfshelp/get-identity.c b/libfshelp/get-identity.c
index 17244de..9f92272 100644
--- a/libfshelp/get-identity.c
+++ b/libfshelp/get-identity.c
@@ -42,7 +42,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 +55,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 +80,9 @@ fshelp_get_identity (struct port_bucket *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);
}
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] branch upstream updated (83fef6c -> 104f312), Samuel Thibault, 2018/01/08
- [hurd] 07/16: libfshelp/get-identity.c: Avoid spurious ihash removal, Samuel Thibault, 2018/01/08
- [hurd] 09/16: libfshelp/get-identity.c: Simplify checking weak references, Samuel Thibault, 2018/01/08
- [hurd] 06/16: libfshelp/get-identity: Use 64bit hashing for inodes, Samuel Thibault, 2018/01/08
- [hurd] 08/16: libihash: Make sure we do not remove a locp several times, Samuel Thibault, 2018/01/08
- [hurd] 02/16: Record executable entry for PIE core dumps, Samuel Thibault, 2018/01/08
- [hurd] 04/16: libfshelp: Add weak reference for hash table reference,
Samuel Thibault <=
- [hurd] 13/16: rpctrace: Pass prefixed_name to _hurd_exec_paths., Samuel Thibault, 2018/01/08
- [hurd] 05/16: libfshelp/get-identity.c: add FIXME, Samuel Thibault, 2018/01/08
- [hurd] 01/16: Reserve IDs for proc_set_exe and proc_get_exe, Samuel Thibault, 2018/01/08
- [hurd] 12/16: Use the new _hurd_exec_file_name function, Samuel Thibault, 2018/01/08
- [hurd] 16/16: Implement /proc/<pid>/exe, Samuel Thibault, 2018/01/08
- [hurd] 14/16: Fix exec_paths through fakeroot or chroot, Samuel Thibault, 2018/01/08
- [hurd] 10/16: Add a new exec_exec_paths RPC, Samuel Thibault, 2018/01/08
- [hurd] 15/16: Add support for $ORIGIN rpath expansion, Samuel Thibault, 2018/01/08
- [hurd] 11/16: Add a file_exec_file_name RPC, Samuel Thibault, 2018/01/08
- [hurd] 03/16: lwip: Add LwIP-based TCP/IP translator, Samuel Thibault, 2018/01/08