diff options
-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 b578f4c61..fef7a5ac9 100644 --- a/networking/ifplugd.c +++ b/networking/ifplugd.c | |||
@@ -289,8 +289,6 @@ static const struct { | |||
289 | { "IFF_RUNNING" , &detect_link_iff }, | 289 | { "IFF_RUNNING" , &detect_link_iff }, |
290 | }; | 290 | }; |
291 | 291 | ||
292 | |||
293 | |||
294 | static const char *strstatus(int status) | 292 | static const char *strstatus(int status) |
295 | { | 293 | { |
296 | if (status == IFSTATUS_ERR) | 294 | if (status == IFSTATUS_ERR) |
@@ -652,7 +650,6 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv) | |||
652 | delay_time = 0; | 650 | delay_time = 0; |
653 | while (1) { | 651 | while (1) { |
654 | int iface_status_old; | 652 | int iface_status_old; |
655 | int iface_exists_old; | ||
656 | 653 | ||
657 | switch (bb_got_signal) { | 654 | switch (bb_got_signal) { |
658 | case SIGINT: | 655 | case SIGINT: |
@@ -678,12 +675,12 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv) | |||
678 | goto exiting; | 675 | goto exiting; |
679 | } | 676 | } |
680 | 677 | ||
681 | iface_status_old = iface_status; | ||
682 | iface_exists_old = G.iface_exists; | ||
683 | |||
684 | if ((opts & FLAG_MONITOR) | 678 | if ((opts & FLAG_MONITOR) |
685 | && (netlink_pollfd[0].revents & POLLIN) | 679 | && (netlink_pollfd[0].revents & POLLIN) |
686 | ) { | 680 | ) { |
681 | int iface_exists_old; | ||
682 | |||
683 | iface_exists_old = G.iface_exists; | ||
687 | G.iface_exists = check_existence_through_netlink(); | 684 | G.iface_exists = check_existence_through_netlink(); |
688 | if (G.iface_exists < 0) /* error */ | 685 | if (G.iface_exists < 0) /* error */ |
689 | goto exiting; | 686 | goto exiting; |
@@ -696,6 +693,7 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv) | |||
696 | } | 693 | } |
697 | 694 | ||
698 | /* note: if !G.iface_exists, returns DOWN */ | 695 | /* note: if !G.iface_exists, returns DOWN */ |
696 | iface_status_old = iface_status; | ||
699 | iface_status = detect_link(); | 697 | iface_status = detect_link(); |
700 | if (iface_status == IFSTATUS_ERR) { | 698 | if (iface_status == IFSTATUS_ERR) { |
701 | if (!(opts & FLAG_MONITOR)) | 699 | if (!(opts & FLAG_MONITOR)) |
@@ -709,7 +707,7 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv) | |||
709 | 707 | ||
710 | if (delay_time) { | 708 | if (delay_time) { |
711 | /* link restored its old status before | 709 | /* link restored its old status before |
712 | * we run script. don't run the script: */ | 710 | * we ran script. don't run the script: */ |
713 | delay_time = 0; | 711 | delay_time = 0; |
714 | } else { | 712 | } else { |
715 | delay_time = monotonic_sec(); | 713 | delay_time = monotonic_sec(); |
@@ -717,15 +715,19 @@ int ifplugd_main(int argc UNUSED_PARAM, char **argv) | |||
717 | delay_time += G.delay_up; | 715 | delay_time += G.delay_up; |
718 | if (iface_status == IFSTATUS_DOWN) | 716 | if (iface_status == IFSTATUS_DOWN) |
719 | delay_time += G.delay_down; | 717 | delay_time += G.delay_down; |
720 | if (delay_time == 0) | 718 | #if 0 /* if you are back in 1970... */ |
721 | delay_time++; | 719 | if (delay_time == 0) { |
720 | sleep(1); | ||
721 | delay_time = 1; | ||
722 | } | ||
723 | #endif | ||
722 | } | 724 | } |
723 | } | 725 | } |
724 | 726 | ||
725 | if (delay_time && (int)(monotonic_sec() - delay_time) >= 0) { | 727 | if (delay_time && (int)(monotonic_sec() - delay_time) >= 0) { |
726 | delay_time = 0; | ||
727 | if (run_script(iface_status_str) != 0) | 728 | if (run_script(iface_status_str) != 0) |
728 | goto exiting; | 729 | goto exiting; |
730 | delay_time = 0; | ||
729 | } | 731 | } |
730 | } /* while (1) */ | 732 | } /* while (1) */ |
731 | 733 | ||