]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
hurd: optimize exec cleanup
authorSamuel Thibault <samuel.thibault@ens-lyon.org>
Sat, 15 Jan 2022 23:02:16 +0000 (00:02 +0100)
committerSamuel Thibault <samuel.thibault@ens-lyon.org>
Sat, 15 Jan 2022 23:02:16 +0000 (00:02 +0100)
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
sysdeps/mach/hurd/dl-sysdep.c

index d5a20cb9b094db888f046c0da3f7d05f9387b547..0545935d801743197196367681f63ece2fca2401 100644 (file)
@@ -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++)
index 6d52558c24289554b3fa0734ee0bcc281871eda7..3cbe075615b94380369d6d945fa499b66eb4813f 100644 (file)
@@ -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++)