slave.c (173412) | slave.c (202204) |
---|---|
1/*- 2 * Copyright (c) 1985, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 22 unchanged lines hidden (view full) --- 31 * SUCH DAMAGE. 32 */ 33 34#ifndef lint 35#if 0 36static char sccsid[] = "@(#)slave.c 8.1 (Berkeley) 6/6/93"; 37#endif 38static const char rcsid[] = | 1/*- 2 * Copyright (c) 1985, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 22 unchanged lines hidden (view full) --- 31 * SUCH DAMAGE. 32 */ 33 34#ifndef lint 35#if 0 36static char sccsid[] = "@(#)slave.c 8.1 (Berkeley) 6/6/93"; 37#endif 38static const char rcsid[] = |
39 "$FreeBSD: head/usr.sbin/timed/timed/slave.c 173412 2007-11-07 10:53:41Z kevlo $"; | 39 "$FreeBSD: head/usr.sbin/timed/timed/slave.c 202204 2010-01-13 18:15:46Z ed $"; |
40#endif /* not lint */ 41 42#include "globals.h" 43#include <setjmp.h> | 40#endif /* not lint */ 41 42#include "globals.h" 43#include <setjmp.h> |
44#include <utmpx.h> |
|
44#include "pathnames.h" 45 46extern jmp_buf jmpenv; 47extern int Mflag; 48extern int justquit; 49 50extern u_short sequence; 51 52static char master_name[MAXHOSTNAMELEN]; 53static struct netinfo *old_slavenet; 54static int old_status; 55 56static void schgdate(struct tsp *, char *); 57static void setmaster(struct tsp *); 58static void answerdelay(void); 59 | 45#include "pathnames.h" 46 47extern jmp_buf jmpenv; 48extern int Mflag; 49extern int justquit; 50 51extern u_short sequence; 52 53static char master_name[MAXHOSTNAMELEN]; 54static struct netinfo *old_slavenet; 55static int old_status; 56 57static void schgdate(struct tsp *, char *); 58static void setmaster(struct tsp *); 59static void answerdelay(void); 60 |
60extern void logwtmp(char *, char *, char *); 61 | |
62int 63slave() 64{ 65 int tries; 66 long electiontime, refusetime, looktime, looptime, adjtime; 67 u_short seq; 68 long fastelection; 69#define FASTTOUT 3 --- 5 unchanged lines hidden (view full) --- 75 struct timeval ntime, wait, tmptv; 76 time_t tsp_time_sec; 77 struct tsp *answer; 78 int timeout(); 79 char olddate[32]; 80 char newdate[32]; 81 struct netinfo *ntp; 82 struct hosttbl *htp; | 61int 62slave() 63{ 64 int tries; 65 long electiontime, refusetime, looktime, looptime, adjtime; 66 u_short seq; 67 long fastelection; 68#define FASTTOUT 3 --- 5 unchanged lines hidden (view full) --- 74 struct timeval ntime, wait, tmptv; 75 time_t tsp_time_sec; 76 struct tsp *answer; 77 int timeout(); 78 char olddate[32]; 79 char newdate[32]; 80 struct netinfo *ntp; 81 struct hosttbl *htp; |
82 struct utmpx utx; |
|
83 84 85 old_slavenet = 0; 86 seq = 0; 87 refusetime = 0; 88 adjtime = 0; 89 90 (void)gettimeofday(&ntime, 0); --- 184 unchanged lines hidden (view full) --- 275 tmptv.tv_usec = msg->tsp_time.tv_usec; 276 timevalsub(&ntime, &tmptv, &otime); 277 if (ntime.tv_sec < MAXADJ && ntime.tv_sec > -MAXADJ) { 278 /* 279 * do not change the clock if we can adjust it 280 */ 281 synch(tvtomsround(ntime)); 282 } else { | 83 84 85 old_slavenet = 0; 86 seq = 0; 87 refusetime = 0; 88 adjtime = 0; 89 90 (void)gettimeofday(&ntime, 0); --- 184 unchanged lines hidden (view full) --- 275 tmptv.tv_usec = msg->tsp_time.tv_usec; 276 timevalsub(&ntime, &tmptv, &otime); 277 if (ntime.tv_sec < MAXADJ && ntime.tv_sec > -MAXADJ) { 278 /* 279 * do not change the clock if we can adjust it 280 */ 281 synch(tvtomsround(ntime)); 282 } else { |
283 logwtmp("|", "date", ""); 284 (void)settimeofday(&tmptv, 0); 285 logwtmp("{", "date", ""); | 283 utx.ut_type = OLD_TIME; 284 gettimeofday(&utx.ut_tv, NULL); 285 pututxline(&utx); 286 (void)settimeofday(&tmptv, 0); 287 utx.ut_type = NEW_TIME; 288 gettimeofday(&utx.ut_tv, NULL); 289 pututxline(&utx); |
286 syslog(LOG_NOTICE, 287 "date changed by %s from %s", 288 msg->tsp_name, olddate); 289 if (status & MASTER) 290 spreadtime(); 291 } 292 (void)gettimeofday(&ntime, 0); 293 electiontime = ntime.tv_sec + delay2; --- 400 unchanged lines hidden --- | 290 syslog(LOG_NOTICE, 291 "date changed by %s from %s", 292 msg->tsp_name, olddate); 293 if (status & MASTER) 294 spreadtime(); 295 } 296 (void)gettimeofday(&ntime, 0); 297 electiontime = ntime.tv_sec + delay2; --- 400 unchanged lines hidden --- |