diff options
author | Denys Vlasenko | 2014-02-10 09:44:25 +0100 |
---|---|---|
committer | Denys Vlasenko | 2014-02-10 09:51:03 +0100 |
commit | 50e4cc29f56b5401579cddaf42d0404320b9efa7 (patch) | |
tree | 935b205ce70efff7188086bf26bf90bc1c79e687 | |
parent | 3e78f6f955ebdc010bb0b8f78622bf701e594b69 (diff) | |
download | busybox-50e4cc29f56b5401579cddaf42d0404320b9efa7.zip busybox-50e4cc29f56b5401579cddaf42d0404320b9efa7.tar.gz |
ifplugd: code shrink
function old new delta
ifplugd_main 1161 1144 -17
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/ifplugd.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/networking/ifplugd.c b/networking/ifplugd.c index b578f4c..fef7a5a 100644 --- a/networking/ifplugd.c +++ b/networking/ifplugd.c @@ -289,8 +289,6 @@ static const struct { { "IFF_RUNNING" , &detect_link_iff }, }; - - static const char *strstatus(int status) { if (status == IFSTATUS_ERR) @@ -652,7 +650,6 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv) delay_time = 0; while (1) { int iface_status_old; - int iface_exists_old; switch (bb_got_signal) { case SIGINT: @@ -678,12 +675,12 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv) goto exiting; } - iface_status_old = iface_status; - iface_exists_old = G.iface_exists; - if ((opts & FLAG_MONITOR) && (netlink_pollfd[0].revents & POLLIN) ) { + int iface_exists_old; + + iface_exists_old = G.iface_exists; G.iface_exists = check_existence_through_netlink(); if (G.iface_exists < 0) /* error */ goto exiting; @@ -696,6 +693,7 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv) } /* note: if !G.iface_exists, returns DOWN */ + iface_status_old = iface_status; iface_status = detect_link(); if (iface_status == IFSTATUS_ERR) { if (!(opts & FLAG_MONITOR)) @@ -709,7 +707,7 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv) if (delay_time) { /* link restored its old status before - * we run script. don't run the script: */ + * we ran script. don't run the script: */ delay_time = 0; } else { delay_time = monotonic_sec(); @@ -717,15 +715,19 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv) delay_time += G.delay_up; if (iface_status == IFSTATUS_DOWN) delay_time += G.delay_down; - if (delay_time == 0) - delay_time++; +#if 0 /* if you are back in 1970... */ + if (delay_time == 0) { + sleep(1); + delay_time = 1; + } +#endif } } if (delay_time && (int)(monotonic_sec() - delay_time) >= 0) { - delay_time = 0; if (run_script(iface_status_str) != 0) goto exiting; + delay_time = 0; } } /* while (1) */ |