svn commit: trunk/busybox/debianutils

vda at busybox.net vda at busybox.net
Sun Apr 20 14:25:26 UTC 2008


Author: vda
Date: 2008-04-20 07:25:26 -0700 (Sun, 20 Apr 2008)
New Revision: 21784

Log:
start_stop_daemon: stat executable only once

function                                             old     new   delta
start_stop_daemon_main                               954     976     +22
check                                               1661    1632     -29
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 22/-29)             Total: -7 bytes



Modified:
   trunk/busybox/debianutils/start_stop_daemon.c


Changeset:
Modified: trunk/busybox/debianutils/start_stop_daemon.c
===================================================================
--- trunk/busybox/debianutils/start_stop_daemon.c	2008-04-20 08:10:37 UTC (rev 21783)
+++ trunk/busybox/debianutils/start_stop_daemon.c	2008-04-20 14:25:26 UTC (rev 21784)
@@ -32,6 +32,7 @@
 	int user_id;
 	smallint quiet;
 	smallint signal_nr;
+	struct stat execstat;
 };
 #define G (*(struct globals*)&bb_common_bufsiz1)
 #define found             (G.found               )
@@ -42,6 +43,7 @@
 #define user_id           (G.user_id             )
 #define quiet             (G.quiet               )
 #define signal_nr         (G.signal_nr           )
+#define execstat          (G.execstat            )
 #define INIT_G() \
         do { \
 		user_id = -1; \
@@ -51,13 +53,12 @@
 
 static int pid_is_exec(pid_t pid)
 {
-	struct stat st, execstat;
+	struct stat st;
 	char buf[sizeof("/proc//exe") + sizeof(int)*3];
 
 	sprintf(buf, "/proc/%u/exe", pid);
 	if (stat(buf, &st) < 0)
 		return 0;
-	xstat(execname, &execstat);
 	if (st.st_dev == execstat.st_dev
 	 && st.st_ino == execstat.st_ino)
 		return 1;
@@ -299,6 +300,8 @@
 		if (errno)
 			user_id = xuname2uid(userspec);
 	}
+	if (execname)
+		xstat(execname, &execstat);
 
 	do_procinit(); /* Both start and stop needs to know current processes */
 




More information about the busybox-cvs mailing list