]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 2622] Synchronisation problem using SHM [...]
authorJuergen Perlinger <perlinger@ntp.org>
Tue, 12 Aug 2014 18:29:54 +0000 (20:29 +0200)
committerJuergen Perlinger <perlinger@ntp.org>
Tue, 12 Aug 2014 18:29:54 +0000 (20:29 +0200)
Add 'control' function to SHM driver-- fudge values not available during start.

bk: 53ea5d229jZMfu7N4xTqNXKxrfa8Hw

ChangeLog
ntpd/refclock_shm.c

index 625f502267c59ce658c366e70b076cd61e407653..50df8222cec1c51002a6b5c27762429359acbb00 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,5 @@
+* [Bug 2622] Synchronisation problem using SHM [...]
+  Add 'control' function -- fudge values not available during start.
 * [Bug 2630] Limit the ntpq command buffer to 512 bytes.
 * FlexeLint cleanups.
 * Try bison-3.0.2 instead of bison-2.5.
index 5c32b81aaed9f9775f854fe0c66c1b3fb3cba3a8..6540e6f377dad64501e370a9d118ad163e6090c9 100644 (file)
@@ -59,6 +59,8 @@ static  void    shm_poll        (int unit, struct peer *peer);
 static  void    shm_timer       (int unit, struct peer *peer);
 static void    shm_peek        (int unit, struct peer *peer);
 static void    shm_clockstats  (int unit, struct peer *peer);
+static void    shm_control     (int unit, const struct refclockstat * in_st,
+                                struct refclockstat * out_st, struct peer *peer);
 
 /*
  * Transfer vector
@@ -67,7 +69,7 @@ struct  refclock refclock_shm = {
        shm_start,              /* start up driver */
        shm_shutdown,           /* shut down driver */
        shm_poll,               /* transmit poll message */
-       noentry,                /* not used: control */
+       shm_control,            /* control settings */
        noentry,                /* not used: init */
        noentry,                /* not used: buginfo */
        shm_timer,              /* once per second */
@@ -214,23 +216,50 @@ shm_start(
                up->shm->valid = 0;
                up->shm->nsamples = NSAMPLES;
                pp->clockdesc = DESCRIPTION;
-
+               /* items to be changed later in 'shm_control()': */
                up->max_delay = 5;
-               if (pp->sloppyclockflag & CLK_FLAG1)
-                       up->max_delta = 0;
-               else if (pp->fudgetime2 < 1. || pp->fudgetime2 > 86400.)
-                       up->max_delta = 4*3600;
-               else
-                       up->max_delta = (time_t)floor(pp->fudgetime2 + 0.5);
-               
+               up->max_delta = 4*3600;
                return 1;
        } else {
                free(up);
+               pp->unitptr = NULL;
                return 0;
        }
 }
 
 
+/*
+ * shm_control - configure flag1/time2 params
+ *
+ * These are not yet available during 'shm_start', so we have to do any
+ * pre-computations we want to avoid during regular poll/timer callbacks
+ * in this callback.
+ */
+static void
+shm_control(
+       int                         unit,
+       const struct refclockstat * in_st,
+       struct refclockstat       * out_st,
+       struct peer               * peer
+       )
+{
+       struct refclockproc *pp;
+       struct shmunit *up;
+
+       pp = peer->procptr;
+       up = pp->unitptr;
+
+       if (NULL == up)
+               return;
+       if (pp->sloppyclockflag & CLK_FLAG1)
+               up->max_delta = 0;
+       else if (pp->fudgetime2 < 1. || pp->fudgetime2 > 86400.)
+               up->max_delta = 4*3600;
+       else
+               up->max_delta = (time_t)floor(pp->fudgetime2 + 0.5);
+}
+
+
 /*
  * shm_shutdown - shut down the clock
  */