commit-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[hurd] 65/98: trans: fix the use of the hash table in fakeroot.c


From: Samuel Thibault
Subject: [hurd] 65/98: trans: fix the use of the hash table in fakeroot.c
Date: Tue, 14 Jan 2014 02:00:03 +0000

This is an automated email from the git hooks/post-receive script.

sthibault pushed a commit to branch upstream
in repository hurd.

commit cf1cc29af12447c347a5574b4dc1568c7db61c0b
Author: Justus Winter <address@hidden>
Date:   Thu Dec 5 19:22:03 2013 +0100

    trans: fix the use of the hash table in fakeroot.c
    
    Previously a pointer to the node was stored in the hash table. This
    writes the locp pointer into the node object overwriting the next
    pointer there. Store the pointer to the netnode instead.
    
    * trans/fakeroot.c (struct netnode): Add field np.
    (new_node): Initialize field np.
    (new_node): Store nn instead of np into the hash table.
    (netfs_S_dir_lookup): Adjust accordingly.
---
 trans/fakeroot.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/trans/fakeroot.c b/trans/fakeroot.c
index 1342844..1ab3216 100644
--- a/trans/fakeroot.c
+++ b/trans/fakeroot.c
@@ -41,6 +41,7 @@ static auth_t fakeroot_auth_port;
 
 struct netnode
 {
+  struct node *np;             /* our node */
   hurd_ihash_locp_t idport_locp;/* easy removal pointer in idport ihash */
   mach_port_t idport;          /* port from io_identity */
   int openmodes;               /* O_READ | O_WRITE | O_EXEC */
@@ -93,7 +94,7 @@ new_node (file_t file, mach_port_t idport, int locked, int 
openmodes,
          return err;
        }
     }
-  *np = netfs_make_node (nn);
+  *np = nn->np = netfs_make_node (nn);
   if (*np == 0)
     {
       if (locked)
@@ -104,7 +105,7 @@ new_node (file_t file, mach_port_t idport, int locked, int 
openmodes,
     {
       if (!locked)
        pthread_mutex_lock (&idport_ihash_lock);
-      err = hurd_ihash_add (&idport_ihash, nn->idport, *np);
+      err = hurd_ihash_add (&idport_ihash, nn->idport, nn);
       if (!err)
        netfs_nref (*np);       /* Return a reference to the caller.  */
       pthread_mutex_unlock (&idport_ihash_lock);
@@ -122,6 +123,7 @@ new_node (file_t file, mach_port_t idport, int locked, int 
openmodes,
 void
 netfs_node_norefs (struct node *np)
 {
+  assert (np->nn->np == np);
   if (np->nn->faked != 0
       && netfs_validate_stat (np, 0) == 0 && np->nn_stat.st_nlink > 0)
     {
@@ -295,9 +297,11 @@ netfs_S_dir_lookup (struct protid *diruser,
       else
        {
          pthread_mutex_lock (&idport_ihash_lock);
-         np = hurd_ihash_find (&idport_ihash, idport);
-         if (np != 0)
+         struct netnode *nn = hurd_ihash_find (&idport_ihash, idport);
+         if (nn != NULL)
            {
+             assert (nn->np->nn == nn);
+             np = nn->np;
              /* We already know about this node.  */
              mach_port_deallocate (mach_task_self (), idport);
              pthread_mutex_lock (&np->lock);

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-hurd/hurd.git



reply via email to

[Prev in Thread] Current Thread [Next in Thread]