Mikhail Karpov, le ven. 30 oct. 2026 18:28:57 +0700, a ecrit: > On Fri, 30 Oct 2026 01:13:14 Samuel Thibault wrote: > > > You could call mach_port_mod_refs even before the first > > mach_port_request_notification. If it fails, we have nothing to do. Then > > we try mach_port_request_notification. If it fails, we just have to > > deallocate transbox->active once to undo the mod_refs, and return. If it > > succeeds, then we can just finish the rest of the operations and return > > success. > > Yes, that simplifies everything a great deal.
Applied, thanks! Samuel > Thanks, > > -- > Mikhail Karpov > From ecaf71e44f219589609b440c597397dd8c4b9389 Mon Sep 17 00:00:00 2001 > From: Mikhail Karpov <[email protected]> > Date: Fri, 30 Oct 2026 17:18:30 +0700 > Subject: [PATCH 2/2] Added checks for mach_port_mod_refs return value in > several place > > --- > libfshelp/translator-list.c | 17 +++++++++++++---- > 1 file changed, 13 insertions(+), 4 deletions(-) > > diff --git a/libfshelp/translator-list.c b/libfshelp/translator-list.c > index 6d4f941..0777fef 100644 > --- a/libfshelp/translator-list.c > +++ b/libfshelp/translator-list.c > @@ -128,14 +128,24 @@ fshelp_set_active_translator (struct port_info *pi, > update: > if (MACH_PORT_VALID (transbox->active) && transbox->active != t->active) > { > + err = mach_port_mod_refs (mach_task_self (), transbox->active, > + MACH_PORT_RIGHT_SEND, +1); > + if (err) > + goto out; > + > mach_port_t old; > - err = mach_port_request_notification (mach_task_self (), > transbox->active, > + err = mach_port_request_notification (mach_task_self (), > + transbox->active, > MACH_NOTIFY_DEAD_NAME, 0, > pi->port_right, > MACH_MSG_TYPE_MAKE_SEND_ONCE, > &old); > if (err) > - goto out; > + { > + mach_port_deallocate (mach_task_self (), transbox->active); > + goto out; > + } > + > if (MACH_PORT_VALID (old)) > mach_port_deallocate (mach_task_self (), old); > > @@ -147,8 +157,7 @@ fshelp_set_active_translator (struct port_info *pi, > > if (MACH_PORT_VALID (t->active)) > mach_port_deallocate (mach_task_self (), t->active); > - mach_port_mod_refs (mach_task_self (), transbox->active, > - MACH_PORT_RIGHT_SEND, +1); > + > t->active = transbox->active; > } > else if (! MACH_PORT_VALID (transbox->active)) > -- > 2.43.0 > -- Samuel R: Parce que ça renverse bêtement l'ordre naturel de lecture! Q: Mais pourquoi citer en fin d'article est-il si effroyable? R: Citer en fin d'article Q: Quelle est la chose la plus désagréable sur les groupes de news?
