Deleted Added
full compact
candidate.c (8857) candidate.c (30642)
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 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#ifndef lint
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 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#ifndef lint
35#if 0
35static char sccsid[] = "@(#)candidate.c 8.1 (Berkeley) 6/6/93";
36static char sccsid[] = "@(#)candidate.c 8.1 (Berkeley) 6/6/93";
37#endif
38static const char rcsid[] =
39 "$Id$";
36#endif /* not lint */
37
40#endif /* not lint */
41
38#ifdef sgi
39#ident "$Revision: 1.1.1.1 $"
40#endif
41
42#include "globals.h"
43
44/*
45 * `election' candidates a host as master: it is called by a slave
46 * which runs with the -M option set when its election timeout expires.
47 * Note the conservative approach: if a new timed comes up, or another
48 * candidate sends an election request, the candidature is withdrawn.
49 */

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

75 }
76
77again:
78 syslog(LOG_INFO, "This machine is a candidate time master");
79 if (trace)
80 fprintf(fd, "This machine is a candidate time master\n");
81 msg.tsp_type = TSP_ELECTION;
82 msg.tsp_vers = TSPVERSION;
42#include "globals.h"
43
44/*
45 * `election' candidates a host as master: it is called by a slave
46 * which runs with the -M option set when its election timeout expires.
47 * Note the conservative approach: if a new timed comes up, or another
48 * candidate sends an election request, the candidature is withdrawn.
49 */

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

75 }
76
77again:
78 syslog(LOG_INFO, "This machine is a candidate time master");
79 if (trace)
80 fprintf(fd, "This machine is a candidate time master\n");
81 msg.tsp_type = TSP_ELECTION;
82 msg.tsp_vers = TSPVERSION;
83 (void)strcpy(msg.tsp_name, hostname);
83 (void)strncpy(msg.tsp_name, hostname, sizeof msg.tsp_name-1);
84 msg.tsp_name[sizeof msg.tsp_name-1] = '\0';
84 bytenetorder(&msg);
85 if (sendto(sock, (char *)&msg, sizeof(struct tsp), 0,
86 (struct sockaddr*)&net->dest_addr,
87 sizeof(struct sockaddr)) < 0) {
88 trace_sendto_err(net->dest_addr.sin_addr);
89 return(SLAVE);
90 }
91

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

134 */
135 rmnetmachs(net);
136 return(SLAVE);
137
138 case TSP_ELECTION:
139 /* no master for another round */
140 htp = addmach(resp->tsp_name,&from,fromnet);
141 msg.tsp_type = TSP_REFUSE;
85 bytenetorder(&msg);
86 if (sendto(sock, (char *)&msg, sizeof(struct tsp), 0,
87 (struct sockaddr*)&net->dest_addr,
88 sizeof(struct sockaddr)) < 0) {
89 trace_sendto_err(net->dest_addr.sin_addr);
90 return(SLAVE);
91 }
92

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

135 */
136 rmnetmachs(net);
137 return(SLAVE);
138
139 case TSP_ELECTION:
140 /* no master for another round */
141 htp = addmach(resp->tsp_name,&from,fromnet);
142 msg.tsp_type = TSP_REFUSE;
142 (void)strcpy(msg.tsp_name, hostname);
143 (void)strncpy(msg.tsp_name, hostname,
144 sizeof msg.tsp_name-1);
145 msg.tsp_name[sizeof msg.tsp_name-1] = '\0';
143 answer = acksend(&msg, &htp->addr, htp->name,
144 TSP_ACK, 0, htp->noanswer);
145 if (!answer) {
146 syslog(LOG_ERR, "error in election from %s",
147 htp->name);
148 }
149 break;
150

--- 17 unchanged lines hidden ---
146 answer = acksend(&msg, &htp->addr, htp->name,
147 TSP_ACK, 0, htp->noanswer);
148 if (!answer) {
149 syslog(LOG_ERR, "error in election from %s",
150 htp->name);
151 }
152 break;
153

--- 17 unchanged lines hidden ---