[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 11/13] trans: improve the error handling in fakeauth
From: |
Samuel Thibault |
Subject: |
Re: [PATCH 11/13] trans: improve the error handling in fakeauth |
Date: |
Tue, 10 Dec 2013 01:12:52 +0100 |
User-agent: |
Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30) |
Justus Winter, le Mon 09 Dec 2013 15:16:39 +0100, a écrit :
> 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.
Ack
> * 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;
> }
>
> --
> 1.7.10.4
>
--
Samuel
Tu as lu les docs. Tu es devenu un informaticien. Que tu le veuilles
ou non. Lire la doc, c'est le Premier et Unique Commandement de
l'informaticien.
-+- TP in: Guide du Linuxien pervers - "L'évangile selon St Thomas"
- Re: [PATCH 04/13] trans: improve the performance of dir_lookup in fakeroot, (continued)
- [PATCH 08/13] trans: fix reference counting and destruction of fake nodes, Justus Winter, 2013/12/09
- [PATCH 11/13] trans: improve the error handling in fakeauth, Justus Winter, 2013/12/09
- Re: [PATCH 11/13] trans: improve the error handling in fakeauth,
Samuel Thibault <=
- [PATCH 09/13] trans: fix locking in fakeroot's netfs_S_dir_lookup, Justus Winter, 2013/12/09
- [PATCH 12/13] trans: unlock nodes with faked attributes in fakeroot, Justus Winter, 2013/12/09
- [PATCH 05/13] trans: handle invalid responses to dir_lookup requests in fakeroot, Justus Winter, 2013/12/09
- [PATCH 10/13] trans: fix reference counting bug in fakeroot, Justus Winter, 2013/12/09
- [PATCH 13/13] console-client: remove spurious pthread_spin_unlocks, Justus Winter, 2013/12/09