diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-04-20 14:25:26 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-04-20 14:25:26 +0000 |
commit | fe493479e2814f25edc270a5605678adbc90086a (patch) | |
tree | d0a3fb90393ce3e2661fc69b51b62eb3e2bd60c9 /debianutils | |
parent | 25cfe4996ec967e19283f6b66c45cf220a615528 (diff) | |
download | busybox-w32-fe493479e2814f25edc270a5605678adbc90086a.tar.gz busybox-w32-fe493479e2814f25edc270a5605678adbc90086a.tar.bz2 busybox-w32-fe493479e2814f25edc270a5605678adbc90086a.zip |
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
Diffstat (limited to 'debianutils')
-rw-r--r-- | debianutils/start_stop_daemon.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/debianutils/start_stop_daemon.c b/debianutils/start_stop_daemon.c index 9150763cb..7a0d1166f 100644 --- a/debianutils/start_stop_daemon.c +++ b/debianutils/start_stop_daemon.c | |||
@@ -32,6 +32,7 @@ struct globals { | |||
32 | int user_id; | 32 | int user_id; |
33 | smallint quiet; | 33 | smallint quiet; |
34 | smallint signal_nr; | 34 | smallint signal_nr; |
35 | struct stat execstat; | ||
35 | }; | 36 | }; |
36 | #define G (*(struct globals*)&bb_common_bufsiz1) | 37 | #define G (*(struct globals*)&bb_common_bufsiz1) |
37 | #define found (G.found ) | 38 | #define found (G.found ) |
@@ -42,6 +43,7 @@ struct globals { | |||
42 | #define user_id (G.user_id ) | 43 | #define user_id (G.user_id ) |
43 | #define quiet (G.quiet ) | 44 | #define quiet (G.quiet ) |
44 | #define signal_nr (G.signal_nr ) | 45 | #define signal_nr (G.signal_nr ) |
46 | #define execstat (G.execstat ) | ||
45 | #define INIT_G() \ | 47 | #define INIT_G() \ |
46 | do { \ | 48 | do { \ |
47 | user_id = -1; \ | 49 | user_id = -1; \ |
@@ -51,13 +53,12 @@ struct globals { | |||
51 | 53 | ||
52 | static int pid_is_exec(pid_t pid) | 54 | static int pid_is_exec(pid_t pid) |
53 | { | 55 | { |
54 | struct stat st, execstat; | 56 | struct stat st; |
55 | char buf[sizeof("/proc//exe") + sizeof(int)*3]; | 57 | char buf[sizeof("/proc//exe") + sizeof(int)*3]; |
56 | 58 | ||
57 | sprintf(buf, "/proc/%u/exe", pid); | 59 | sprintf(buf, "/proc/%u/exe", pid); |
58 | if (stat(buf, &st) < 0) | 60 | if (stat(buf, &st) < 0) |
59 | return 0; | 61 | return 0; |
60 | xstat(execname, &execstat); | ||
61 | if (st.st_dev == execstat.st_dev | 62 | if (st.st_dev == execstat.st_dev |
62 | && st.st_ino == execstat.st_ino) | 63 | && st.st_ino == execstat.st_ino) |
63 | return 1; | 64 | return 1; |
@@ -299,6 +300,8 @@ int start_stop_daemon_main(int argc ATTRIBUTE_UNUSED, char **argv) | |||
299 | if (errno) | 300 | if (errno) |
300 | user_id = xuname2uid(userspec); | 301 | user_id = xuname2uid(userspec); |
301 | } | 302 | } |
303 | if (execname) | ||
304 | xstat(execname, &execstat); | ||
302 | 305 | ||
303 | do_procinit(); /* Both start and stop needs to know current processes */ | 306 | do_procinit(); /* Both start and stop needs to know current processes */ |
304 | 307 | ||