Skip to content

Loading…

Better control of stopping daemon before syncing time #1100

Merged
merged 3 commits into from

2 participants

@javierag
Zentyal member

No description provided.

@jacalvo jacalvo merged commit a8b34e7 into master

1 check passed

Details default Merged build finished.
@jacalvo jacalvo deleted the jag/ntp-daemon-fixes branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 7, 2014
  1. @javierag
  2. @javierag

    remove debug

    javierag committed
  3. @javierag

    typo fix

    javierag committed
Showing with 12 additions and 10 deletions.
  1. +1 −0 main/ntp/ChangeLog
  2. +11 −10 main/ntp/src/EBox/NTP.pm
View
1 main/ntp/ChangeLog
@@ -1,4 +1,5 @@
3.4
+ + Better control of stopping daemon before syncing time
+ Save module config after initialSetup
+ Use service instead of deprecated invoke-rc.d for init.d scripts
+ Set version to 3.4
View
21 main/ntp/src/EBox/NTP.pm
@@ -29,6 +29,7 @@ use EBox::Menu::Folder;
use TryCatch::Lite;
use EBox::Validate qw(:all);
use EBox::Sudo;
+use Time::HiRes qw(usleep);
use EBox;
use constant NTPCONFFILE => '/etc/ntp.conf';
@@ -67,15 +68,6 @@ sub appArmorProfiles
];
}
-sub isRunning
-{
- my ($self) = @_;
- # return undef if service is not enabled
- # otherwise it might be misleading if time synchronization is set
- ($self->isEnabled()) or return undef;
- return EBox::Service::running('ebox.ntpd');
-}
-
# Method: actions
#
# Override EBox::Module::Service::actions
@@ -171,7 +163,16 @@ sub _preSetConf
try {
$self->_stopService();
- sleep 2;
+ # wait for ntpd daemon stop
+ my $tries = 4000;
+ while ($self->isRunning()) {
+ usleep(1000);
+ $tries -= 1;
+ if ($tries == 0) {
+ EBox::error("Cannot stop zentyal ntp daemon");
+ last;
+ }
+ }
$self->_syncDate();
} catch {
}
Something went wrong with that request. Please try again.