* [hurd,commited] hurd: optimize exec cleanup
@ 2022-01-15 23:27 Samuel Thibault
0 siblings, 0 replies; only message in thread
From: Samuel Thibault @ 2022-01-15 23:27 UTC (permalink / raw)
To: libc-alpha; +Cc: Samuel Thibault, commit-hurd
When ports are nul we do not need to request their deallocation. It is
also useless to look for them in portnames.
---
hurd/hurdexec.c | 26 ++++++++++++++------------
sysdeps/mach/hurd/dl-sysdep.c | 26 ++++++++++++++------------
2 files changed, 28 insertions(+), 24 deletions(-)
diff --git a/hurd/hurdexec.c b/hurd/hurdexec.c
index d5a20cb9b0..0545935d80 100644
--- a/hurd/hurdexec.c
+++ b/hurd/hurdexec.c
@@ -383,19 +383,21 @@ retry:
exec call. */
for (i = 0; i < _hurd_nports; ++i)
- {
- *pdp++ = ports[i];
- for (j = 0; j < nportnames; j++)
- if (portnames[j] == ports[i])
- portnames[j] = MACH_PORT_NULL;
- }
+ if (ports[i] != MACH_PORT_NULL)
+ {
+ *pdp++ = ports[i];
+ for (j = 0; j < nportnames; j++)
+ if (portnames[j] == ports[i])
+ portnames[j] = MACH_PORT_NULL;
+ }
for (i = 0; i < dtablesize; ++i)
- {
- *pdp++ = dtable[i];
- for (j = 0; j < nportnames; j++)
- if (portnames[j] == dtable[i])
- portnames[j] = MACH_PORT_NULL;
- }
+ if (dtable[i] != MACH_PORT_NULL)
+ {
+ *pdp++ = dtable[i];
+ for (j = 0; j < nportnames; j++)
+ if (portnames[j] == dtable[i])
+ portnames[j] = MACH_PORT_NULL;
+ }
/* Pack ports to be destroyed together. */
for (i = 0, j = 0; i < nportnames; i++)
diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c
index 6d52558c24..3cbe075615 100644
--- a/sysdeps/mach/hurd/dl-sysdep.c
+++ b/sysdeps/mach/hurd/dl-sysdep.c
@@ -611,19 +611,21 @@ __rtld_execve (const char *file_name, char *const argv[],
}
for (i = 0; i < portarraysize; ++i)
- {
- *pdp++ = ports[i];
- for (j = 0; j < nportnames; j++)
- if (portnames[j] == ports[i])
- portnames[j] = MACH_PORT_NULL;
- }
+ if (ports[i] != MACH_PORT_NULL)
+ {
+ *pdp++ = ports[i];
+ for (j = 0; j < nportnames; j++)
+ if (portnames[j] == ports[i])
+ portnames[j] = MACH_PORT_NULL;
+ }
for (i = 0; i < dtablesize; ++i)
- {
- *pdp++ = dtable[i];
- for (j = 0; j < nportnames; j++)
- if (portnames[j] == dtable[i])
- portnames[j] = MACH_PORT_NULL;
- }
+ if (dtable[i] != MACH_PORT_NULL)
+ {
+ *pdp++ = dtable[i];
+ for (j = 0; j < nportnames; j++)
+ if (portnames[j] == dtable[i])
+ portnames[j] = MACH_PORT_NULL;
+ }
/* Pack ports to be destroyed together. */
for (i = 0, j = 0; i < nportnames; i++)
--
2.34.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-01-15 23:27 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-15 23:27 [hurd,commited] hurd: optimize exec cleanup Samuel Thibault
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).