Deleted Added
full compact
slave.c (239991) slave.c (246209)
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

--- 18 unchanged lines hidden (view full) ---

27 * SUCH DAMAGE.
28 */
29
30#ifndef lint
31#if 0
32static char sccsid[] = "@(#)slave.c 8.1 (Berkeley) 6/6/93";
33#endif
34static 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

--- 18 unchanged lines hidden (view full) ---

27 * SUCH DAMAGE.
28 */
29
30#ifndef lint
31#if 0
32static char sccsid[] = "@(#)slave.c 8.1 (Berkeley) 6/6/93";
33#endif
34static const char rcsid[] =
35 "$FreeBSD: head/usr.sbin/timed/timed/slave.c 239991 2012-09-01 14:45:15Z ed $";
35 "$FreeBSD: head/usr.sbin/timed/timed/slave.c 246209 2013-02-01 14:26:54Z charnier $";
36#endif /* not lint */
37
38#include "globals.h"
39#include <setjmp.h>
40#include <utmpx.h>
41#include "pathnames.h"
42
43extern jmp_buf jmpenv;

--- 6 unchanged lines hidden (view full) ---

50static struct netinfo *old_slavenet;
51static int old_status;
52
53static void schgdate(struct tsp *, char *);
54static void setmaster(struct tsp *);
55static void answerdelay(void);
56
57int
36#endif /* not lint */
37
38#include "globals.h"
39#include <setjmp.h>
40#include <utmpx.h>
41#include "pathnames.h"
42
43extern jmp_buf jmpenv;

--- 6 unchanged lines hidden (view full) ---

50static struct netinfo *old_slavenet;
51static int old_status;
52
53static void schgdate(struct tsp *, char *);
54static void setmaster(struct tsp *);
55static void answerdelay(void);
56
57int
58slave()
58slave(void)
59{
60 int tries;
61 long electiontime, refusetime, looktime, looptime, adjtime;
62 u_short seq;
63 long fastelection;
64#define FASTTOUT 3
65 struct in_addr cadr;
66 struct timeval otime;

--- 538 unchanged lines hidden (view full) ---

605 goto loop;
606}
607
608
609/*
610 * tell the world who our master is
611 */
612static void
59{
60 int tries;
61 long electiontime, refusetime, looktime, looptime, adjtime;
62 u_short seq;
63 long fastelection;
64#define FASTTOUT 3
65 struct in_addr cadr;
66 struct timeval otime;

--- 538 unchanged lines hidden (view full) ---

605 goto loop;
606}
607
608
609/*
610 * tell the world who our master is
611 */
612static void
613setmaster(msg)
614 struct tsp *msg;
613setmaster(struct tsp *msg)
615{
616 if (slavenet
617 && (slavenet != old_slavenet
618 || strcmp(msg->tsp_name, master_name)
619 || old_status != status)) {
620 (void)strcpy(master_name, msg->tsp_name);
621 old_slavenet = slavenet;
622 old_status = status;

--- 12 unchanged lines hidden (view full) ---

635}
636
637
638
639/*
640 * handle date change request on a slave
641 */
642static void
614{
615 if (slavenet
616 && (slavenet != old_slavenet
617 || strcmp(msg->tsp_name, master_name)
618 || old_status != status)) {
619 (void)strcpy(master_name, msg->tsp_name);
620 old_slavenet = slavenet;
621 old_status = status;

--- 12 unchanged lines hidden (view full) ---

634}
635
636
637
638/*
639 * handle date change request on a slave
640 */
641static void
643schgdate(msg, newdate)
644 struct tsp *msg;
645 char *newdate;
642schgdate(struct tsp *msg, char *newdate)
646{
647 struct tsp to;
648 u_short seq;
649 struct sockaddr_in taddr;
650 struct timeval otime;
651
652 if (!slavenet)
653 return; /* no where to forward */

--- 21 unchanged lines hidden (view full) ---

675}
676
677
678/*
679 * Used before answering a broadcast message to avoid network
680 * contention and likely collisions.
681 */
682static void
643{
644 struct tsp to;
645 u_short seq;
646 struct sockaddr_in taddr;
647 struct timeval otime;
648
649 if (!slavenet)
650 return; /* no where to forward */

--- 21 unchanged lines hidden (view full) ---

672}
673
674
675/*
676 * Used before answering a broadcast message to avoid network
677 * contention and likely collisions.
678 */
679static void
683answerdelay()
680answerdelay(void)
684{
685 struct timeval timeout;
686
687 timeout.tv_sec = 0;
688 timeout.tv_usec = delay1;
689
690 (void)select(0, (fd_set *)NULL, (fd_set *)NULL, (fd_set *)NULL,
691 &timeout);
692 return;
693}
681{
682 struct timeval timeout;
683
684 timeout.tv_sec = 0;
685 timeout.tv_usec = delay1;
686
687 (void)select(0, (fd_set *)NULL, (fd_set *)NULL, (fd_set *)NULL,
688 &timeout);
689 return;
690}