[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 73/98: trans: improve the error handling in fakeauth
From: |
Samuel Thibault |
Subject: |
[hurd] 73/98: trans: improve the error handling in fakeauth |
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 2640c8a8e32c2f20023e4cb91f87684c62316f19
Author: Justus Winter <address@hidden>
Date: Fri Dec 6 00:04:39 2013 +0100
trans: improve the error handling in fakeauth
Previously the node was not correctly torn down if adding the newly
created netnode to the hash table failed. Fix this by rearranging the
code, doing the hash table modification first because it is easier to
undo.
* trans/fakeroot.c (new_node): Fix the error handling.
---
trans/fakeroot.c | 37 ++++++++++++++++++++-----------------
1 file changed, 20 insertions(+), 17 deletions(-)
diff --git a/trans/fakeroot.c b/trans/fakeroot.c
index 5c4854d..3756f48 100644
--- a/trans/fakeroot.c
+++ b/trans/fakeroot.c
@@ -95,28 +95,31 @@ new_node (file_t file, mach_port_t idport, int locked, int
openmodes,
return err;
}
}
+
+ if (!locked)
+ pthread_mutex_lock (&idport_ihash_lock);
+ err = hurd_ihash_add (&idport_ihash, nn->idport, nn);
+ if (err)
+ goto lose;
+
*np = nn->np = netfs_make_node (nn);
if (*np == 0)
{
- if (locked)
- pthread_mutex_unlock (&idport_ihash_lock);
err = ENOMEM;
+ goto lose_hash;
}
- else
- {
- if (!locked)
- pthread_mutex_lock (&idport_ihash_lock);
- err = hurd_ihash_add (&idport_ihash, nn->idport, nn);
- if (!err)
- pthread_mutex_lock (&(*np)->lock);
- pthread_mutex_unlock (&idport_ihash_lock);
- }
- if (err)
- {
- mach_port_deallocate (mach_task_self (), nn->idport);
- mach_port_deallocate (mach_task_self (), file);
- free (nn);
- }
+
+ pthread_mutex_lock (&(*np)->lock);
+ pthread_mutex_unlock (&idport_ihash_lock);
+ return 0;
+
+ lose_hash:
+ hurd_ihash_locp_remove (&idport_ihash, nn->idport_locp);
+ lose:
+ pthread_mutex_unlock (&idport_ihash_lock);
+ mach_port_deallocate (mach_task_self (), nn->idport);
+ mach_port_deallocate (mach_task_self (), file);
+ free (nn);
return err;
}
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 41/98: libports: improve error handling in ports_reallocate_from_external, (continued)
- [hurd] 41/98: libports: improve error handling in ports_reallocate_from_external, Samuel Thibault, 2014/01/13
- [hurd] 40/98: libports: improve error handling in ports_reallocate_port, Samuel Thibault, 2014/01/13
- [hurd] 58/98: trans: remove unused declaration from fakeroot.c, Samuel Thibault, 2014/01/13
- [hurd] 72/98: trans: fix reference counting bug in fakeroot, Samuel Thibault, 2014/01/13
- [hurd] 39/98: proc: update comments, Samuel Thibault, 2014/01/13
- [hurd] 26/98: Make sure created netfs nodes have stat validated, Samuel Thibault, 2014/01/13
- [hurd] 53/98: proc: improve the message_demuxer function, Samuel Thibault, 2014/01/13
- [hurd] 04/98: utils: implement settrans --pid-file, Samuel Thibault, 2014/01/13
- [hurd] 59/98: trans: improve the netfs_demuxer function in fakeroot.c, Samuel Thibault, 2014/01/13
- [hurd] 48/98: libports: another right leak fix, Samuel Thibault, 2014/01/13
- [hurd] 73/98: trans: improve the error handling in fakeauth,
Samuel Thibault <=
- [hurd] 06/98: proc: fix the declaraton of genpid, Samuel Thibault, 2014/01/13
- [hurd] 71/98: trans: fix locking in fakeroot's netfs_S_dir_lookup, Samuel Thibault, 2014/01/13
- [hurd] 70/98: trans: fix reference counting and destruction of fake nodes, Samuel Thibault, 2014/01/13
- [hurd] 77/98: trans/fakeroot: fix ownership of newly created files, Samuel Thibault, 2014/01/13
- [hurd] 64/98: libihash: remove dead code, Samuel Thibault, 2014/01/13
- [hurd] 74/98: trans: unlock nodes with faked attributes in fakeroot, Samuel Thibault, 2014/01/13
- [hurd] 75/98: console-client: remove spurious pthread_spin_unlocks, Samuel Thibault, 2014/01/13
- [hurd] 62/98: trans: make the fakeroot environment more transparent, Samuel Thibault, 2014/01/13
- [hurd] 14/98: proc: turn count_up and store_pid into normal functions, Samuel Thibault, 2014/01/13
- [hurd] 67/98: trans: handle invalid responses to dir_lookup requests in fakeroot, Samuel Thibault, 2014/01/13