]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
settimeofday() fix in configure, do a better job tracking and
authorHarlan Stenn <stenn@ntp.org>
Sun, 2 Dec 2001 09:12:13 +0000 (04:12 -0500)
committerHarlan Stenn <stenn@ntp.org>
Sun, 2 Dec 2001 09:12:13 +0000 (04:12 -0500)
reporting progress in ntp_set_tod().

bk: 3c09f06dYV7tKVCw_-2Rg2L7zqfOZw

configure.in
libntp/machines.c

index 5711ebe0dbc2b6f0bf9b379e654ccf9fda1db76a..12d4366cb50b00f30beaa58014cec23c2c87ce5f 100644 (file)
@@ -650,7 +650,7 @@ case "$target" in
     ;;
 esac
 AC_CHECK_FUNCS(setlinebuf setpgid setpriority setsid)
-AC_CHECK_FUNC(settimeofday, ,[
+AC_CHECK_FUNCS(settimeofday, ,[
 case "$target" in
   *-*-mpeix*) ac_cv_func_settimeofday=yes
     ;;
index ebb3fb4e4bb577e22436dec5ed63110be738ea9f..8a62e24405dbd8e6763a0457e8e960355961d5ad 100644 (file)
@@ -417,48 +417,67 @@ ntp_set_tod(
        void *tzp
        )
 {
-       int rc;
+       int rc = -1;
+
+#ifdef DEBUG
+       if (debug)
+           printf("In ntp_set_tod\n");
+#endif
 
 #ifdef HAVE_CLOCK_SETTIME
-       {
+       if (rc) {
                struct timespec ts;
 
+               set_tod_using = "clock_settime";
                /* Convert timeval to timespec */
                ts.tv_sec = tvp->tv_sec;
                ts.tv_nsec = 1000 *  tvp->tv_usec;
 
+               errno = 0;
                rc = clock_settime(CLOCK_REALTIME, &ts);
-               if (!rc)
-               {
-                       set_tod_using = "clock_settime";
-                       return rc;
-               }
        }
+#ifdef DEBUG
+       if (debug) {
+               printf("ntp_set_tod: %s: %d: %s\n",
+                       set_tod_using, rc, strerror(errno));
+       }
+#endif
 #endif /* HAVE_CLOCK_SETTIME */
 #ifdef HAVE_SETTIMEOFDAY
-       {
+       if (rc) {
+               set_tod_using = "settimeofday";
                rc = SETTIMEOFDAY(tvp, tzp);
-               if (!rc)
-               {
-                       set_tod_using = "settimeofday";
-                       return rc;
-               }
        }
+#ifdef DEBUG
+       if (debug) {
+               printf("ntp_set_tod: %s: %d: %s\n",
+                       set_tod_using, rc, strerror(errno));
+       }
+#endif
 #endif /* HAVE_SETTIMEOFDAY */
 #ifdef HAVE_STIME
-       {
+       if (rc) {
                long tp = tvp->tv_sec;
 
+               set_tod_using = "stime";
                rc = stime(&tp); /* lie as bad as SysVR4 */
-               if (!rc)
-               {
-                       set_tod_using = "stime";
-                       return rc;
-               }
        }
+#ifdef DEBUG
+       if (debug) {
+               printf("ntp_set_tod: %s: %d: %s\n",
+                       set_tod_using, rc, strerror(errno));
+       }
+#endif
 #endif /* HAVE_STIME */
-       set_tod_using = "Failed!";
-       return -1;
+       if (rc)
+           set_tod_using = "Failed!";
+#ifdef DEBUG
+       if (debug) {
+               printf("ntp_set_tod: Final: %s: %d: %s\n",
+                       set_tod_using, rc, strerror(errno));
+       }
+#endif
+       return rc;
 }
 
 #endif /* not SYS_WINNT */