|
From: <wow...@us...> - 2015-10-14 16:50:36
|
Revision: 592
http://sourceforge.net/p/ptpd/code/592
Author: wowczarek
Date: 2015-10-14 16:50:33 +0000 (Wed, 14 Oct 2015)
Log Message:
-----------
- renamed leap seconds file to non-date specific
- leap seconds file in default path added to
utc properties template
- changed dictionary_del to use double pointer,
and nullify the underlying pointer so we
can safely call dictionary_del multiple times
- small exit memory leak fixed as a result
of not deleting dictionaries on early
failure
- added log message body hash computation, same
message is not logged twice unless compiled
with debug enabled
- rand seed at startup
Modified Paths:
--------------
trunk/Makefile.am
trunk/packagebuild/rpm-rh/ptpd.spec
trunk/src/Makefile.am
trunk/src/arith.c
trunk/src/dep/configdefaults.c
trunk/src/dep/daemonconfig.c
trunk/src/dep/datatypes_dep.h
trunk/src/dep/iniparser/dictionary.c
trunk/src/dep/iniparser/dictionary.h
trunk/src/dep/iniparser/iniparser.c
trunk/src/dep/iniparser/iniparser.h
trunk/src/dep/startup.c
trunk/src/dep/sys.c
trunk/src/protocol.c
trunk/src/ptpd.h
Added Paths:
-----------
trunk/src/leap-seconds.list
Removed Paths:
-------------
trunk/src/leap-seconds.list.28dec2015
Modified: trunk/Makefile.am
===================================================================
--- trunk/Makefile.am 2015-10-14 07:16:38 UTC (rev 591)
+++ trunk/Makefile.am 2015-10-14 16:50:33 UTC (rev 592)
@@ -19,7 +19,7 @@
src/ptpd2.conf.minimal\
src/ptpd2.8\
src/ptpd2.conf.5\
- src/leap-seconds.list.28dec2015\
+ src/leap-seconds.list\
src/dep/iniparser/AUTHORS\
src/dep/iniparser/LICENSE\
src/dep/iniparser/README\
@@ -37,7 +37,7 @@
$(NULL)
ptpd2dir = $(datadir)/$(PACKAGE)
-ptpd2_DATA = src/leap-seconds.list.28dec2015 \
+ptpd2_DATA = src/leap-seconds.list \
src/ptpd2.conf.minimal \
src/ptpd2.conf.default-full \
doc/PTPBASE-MIB.txt \
Modified: trunk/packagebuild/rpm-rh/ptpd.spec
===================================================================
--- trunk/packagebuild/rpm-rh/ptpd.spec 2015-10-14 07:16:38 UTC (rev 591)
+++ trunk/packagebuild/rpm-rh/ptpd.spec 2015-10-14 16:50:33 UTC (rev 592)
@@ -95,7 +95,7 @@
install -m 644 src/ptpd2.8 $RPM_BUILD_ROOT%{_mandir}/man8/ptpd2.8
install -m 644 src/ptpd2.conf.5 $RPM_BUILD_ROOT%{_mandir}/man5/ptpd2.conf.5
install -m 644 doc/PTPBASE-MIB.txt $RPM_BUILD_ROOT%{_datadir}/snmp/mibs/PTPBASE-MIB.txt
-install -m 644 src/leap-seconds.list.28dec2015 $RPM_BUILD_ROOT%{_datadir}/ptpd/leap-seconds.list.28dec2015
+install -m 644 src/leap-seconds.list $RPM_BUILD_ROOT%{_datadir}/ptpd/leap-seconds.list
install -m 644 src/ptpd2.conf.minimal $RPM_BUILD_ROOT%{_datadir}/ptpd/ptpd2.conf.minimal
install -m 644 src/ptpd2.conf.default-full $RPM_BUILD_ROOT%{_datadir}/ptpd/ptpd2.conf.default-full
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2015-10-14 07:16:38 UTC (rev 591)
+++ trunk/src/Makefile.am 2015-10-14 16:50:33 UTC (rev 592)
@@ -12,9 +12,8 @@
if LINUX_KERNEL_HEADERS
AM_CFLAGS += $(LINUX_KERNEL_INCLUDES)
endif
+AM_CPPFLAGS += -DDATADIR='"$(datadir)"' $(PTP_DBL) $(PTP_DAEMON) $(PTP_EXP) $(PTP_SNMP) $(PTP_PCAP) $(PTP_STATISTICS) $(PTP_SLAVE_ONLY) $(PTP_PTIMERS) $(PTP_UNICAST_MAX) $(PTP_DISABLE_SOTIMESTAMPING)
-AM_CPPFLAGS += $(PTP_DBL) $(PTP_DAEMON) $(PTP_EXP) $(PTP_SNMP) $(PTP_PCAP) $(PTP_STATISTICS) $(PTP_SLAVE_ONLY) $(PTP_PTIMERS) $(PTP_UNICAST_MAX) $(PTP_DISABLE_SOTIMESTAMPING)
-
NULL=
#VERSION = 2.3.1
Modified: trunk/src/arith.c
===================================================================
--- trunk/src/arith.c 2015-10-14 07:16:38 UTC (rev 591)
+++ trunk/src/arith.c 2015-10-14 16:50:33 UTC (rev 592)
@@ -1,4 +1,5 @@
/*-
+ * Copyright (c) 2012-2015 Wojciech Owczarek,
* Copyright (c) 2011-2012 George V. Neville-Neil,
* Steven Kreuzer,
* Martin Burnicki,
Modified: trunk/src/dep/configdefaults.c
===================================================================
--- trunk/src/dep/configdefaults.c 2015-10-14 07:16:38 UTC (rev 591)
+++ trunk/src/dep/configdefaults.c 2015-10-14 16:50:33 UTC (rev 592)
@@ -95,7 +95,7 @@
{"ptpengine:ptp_timescale","PTP"},
{"ptpengine:time_traceable","y"},
{"ptpengine:frequency_traceable","y"},
- {"clock:leap_seconds_file",""},
+ {"clock:leap_seconds_file", DATADIR"/"PACKAGE_NAME"/leap-seconds.list"},
{NULL}}
},
Modified: trunk/src/dep/daemonconfig.c
===================================================================
--- trunk/src/dep/daemonconfig.c 2015-10-14 07:16:38 UTC (rev 591)
+++ trunk/src/dep/daemonconfig.c 2015-10-14 16:50:33 UTC (rev 592)
@@ -2279,7 +2279,7 @@
return target;
}
- dictionary_del(target);
+ dictionary_del(&target);
return NULL;
@@ -2305,7 +2305,7 @@
HELP_END();
dictionary_merge( dict, *target, 0, NULL);
- dictionary_del(dict);
+ dictionary_del(&dict);
return TRUE;
}
@@ -2404,7 +2404,7 @@
/* NULL will always be returned in this mode */
parseConfig(dict, &rtOpts);
END_SHOWDEFAULT();
- dictionary_del(dict);
+ dictionary_del(&dict);
printf("\n; ========= newline required in the end ==========\n\n");
@@ -2434,7 +2434,7 @@
parseConfig(dict, &rtOpts);
HELP_END();
- dictionary_del(dict);
+ dictionary_del(&dict);
}
@@ -2464,7 +2464,7 @@
printf("Use -H or --long-help to show help for all settings.\n\n");
HELP_END();
- dictionary_del(dict);
+ dictionary_del(&dict);
}
/**
Modified: trunk/src/dep/datatypes_dep.h
===================================================================
--- trunk/src/dep/datatypes_dep.h 2015-10-14 07:16:38 UTC (rev 591)
+++ trunk/src/dep/datatypes_dep.h 2015-10-14 16:50:33 UTC (rev 592)
@@ -133,6 +133,7 @@
Boolean truncateOnReopen;
Boolean unlinkOnClose;
+ uint32_t lastHash;
UInteger32 maxSize;
UInteger32 fileSize;
int maxFiles;
Modified: trunk/src/dep/iniparser/dictionary.c
===================================================================
--- trunk/src/dep/iniparser/dictionary.c 2015-10-14 07:16:38 UTC (rev 591)
+++ trunk/src/dep/iniparser/dictionary.c 2015-10-14 16:50:33 UTC (rev 592)
@@ -140,21 +140,22 @@
Deallocate a dictionary object and all memory associated to it.
*/
/*--------------------------------------------------------------------------*/
-void dictionary_del(dictionary * d)
+void dictionary_del(dictionary ** d)
{
int i ;
- if (d==NULL) return ;
- for (i=0 ; i<d->size ; i++) {
- if (d->key[i]!=NULL)
- free(d->key[i]);
- if (d->val[i]!=NULL)
- free(d->val[i]);
+ if (*d==NULL) return ;
+ for (i=0 ; i<(*d)->size ; i++) {
+ if ((*d)->key[i]!=NULL)
+ free((*d)->key[i]);
+ if ((*d)->val[i]!=NULL)
+ free((*d)->val[i]);
}
- free(d->val);
- free(d->key);
- free(d->hash);
- free(d);
+ free((*d)->val);
+ free((*d)->key);
+ free((*d)->hash);
+ free(*d);
+ *d = NULL;
return ;
}
@@ -500,7 +501,7 @@
printf("error deleting values\n");
}
printf("deallocating...\n");
- dictionary_del(d);
+ dictionary_del(&d);
return 0 ;
}
#endif
Modified: trunk/src/dep/iniparser/dictionary.h
===================================================================
--- trunk/src/dep/iniparser/dictionary.h 2015-10-14 07:16:38 UTC (rev 591)
+++ trunk/src/dep/iniparser/dictionary.h 2015-10-14 16:50:33 UTC (rev 592)
@@ -95,7 +95,7 @@
Deallocate a dictionary object and all memory associated to it.
*/
/*--------------------------------------------------------------------------*/
-void dictionary_del(dictionary * vd);
+void dictionary_del(dictionary ** vd);
/*-------------------------------------------------------------------------*/
/**
Modified: trunk/src/dep/iniparser/iniparser.c
===================================================================
--- trunk/src/dep/iniparser/iniparser.c 2015-10-14 07:16:38 UTC (rev 591)
+++ trunk/src/dep/iniparser/iniparser.c 2015-10-14 16:50:33 UTC (rev 592)
@@ -677,7 +677,7 @@
"iniparser: input line too long or no newline in the end in %s (%d)\n",
ininame,
lineno);
- dictionary_del(dict);
+ dictionary_del(&dict);
fclose(in);
return NULL ;
}
@@ -728,7 +728,7 @@
}
}
if (errs) {
- dictionary_del(dict);
+ dictionary_del(&dict);
dict = NULL ;
}
fclose(in);
@@ -746,7 +746,7 @@
gets out of the current context.
*/
/*--------------------------------------------------------------------------*/
-void iniparser_freedict(dictionary * d)
+void iniparser_freedict(dictionary ** d)
{
dictionary_del(d);
}
Modified: trunk/src/dep/iniparser/iniparser.h
===================================================================
--- trunk/src/dep/iniparser/iniparser.h 2015-10-14 07:16:38 UTC (rev 591)
+++ trunk/src/dep/iniparser/iniparser.h 2015-10-14 16:50:33 UTC (rev 592)
@@ -302,6 +302,6 @@
gets out of the current context.
*/
/*--------------------------------------------------------------------------*/
-void iniparser_freedict(dictionary * d);
+void iniparser_freedict(dictionary ** d);
#endif
Modified: trunk/src/dep/startup.c
===================================================================
--- trunk/src/dep/startup.c 2015-10-14 07:16:38 UTC (rev 591)
+++ trunk/src/dep/startup.c 2015-10-14 16:50:33 UTC (rev 592)
@@ -167,7 +167,7 @@
/* Try reloading the config file */
NOTIFY("Reloading configuration file: %s\n",rtOpts->configFile);
if(!loadConfigFile(&tmpConfig, rtOpts)) {
- dictionary_del(tmpConfig);
+ dictionary_del(&tmpConfig);
goto end;
}
dictionary_merge(rtOpts->cliConfig, tmpConfig, 1, "from command line");
@@ -178,7 +178,7 @@
/* Check the new configuration for errors, fill in the blanks from defaults */
if( ( rtOpts->candidateConfig = parseConfig(tmpConfig,&tmpOpts)) == NULL ) {
WARNING("Configuration file has errors, reload aborted\n");
- dictionary_del(tmpConfig);
+ dictionary_del(&tmpConfig);
goto end;
}
@@ -254,7 +254,7 @@
* disable quiet mode to show what went wrong, then die.
*/
if (rtOpts->currentConfig) {
- dictionary_del(rtOpts->currentConfig);
+ dictionary_del(&rtOpts->currentConfig);
}
if ( (rtOpts->currentConfig = parseConfig(rtOpts->candidateConfig,rtOpts)) == NULL) {
CRITICAL("************ "PTPD_PROGNAME": parseConfig returned NULL during config commit"
@@ -274,8 +274,8 @@
/* clean up */
cleanup:
- dictionary_del(tmpConfig);
- dictionary_del(rtOpts->candidateConfig);
+ dictionary_del(&tmpConfig);
+ dictionary_del(&rtOpts->candidateConfig);
end:
@@ -592,9 +592,9 @@
#endif /* PTPD_STATISTICS */
if (rtOpts.currentConfig != NULL)
- dictionary_del(rtOpts.currentConfig);
+ dictionary_del(&rtOpts.currentConfig);
if(rtOpts.cliConfig != NULL)
- dictionary_del(rtOpts.cliConfig);
+ dictionary_del(&rtOpts.cliConfig);
timerShutdown(ptpClock->timers);
@@ -651,6 +651,7 @@
ptpdStartup(int argc, char **argv, Integer16 * ret, RunTimeOpts * rtOpts)
{
PtpClock * ptpClock;
+ TimeInternal tmpTime;
int i = 0;
/*
@@ -660,6 +661,10 @@
*/
umask(~DEFAULT_FILE_PERMS);
+ /* get some entropy in... */
+ getTime(&tmpTime);
+ srand(tmpTime.seconds ^ tmpTime.nanoseconds);
+
/**
* If a required setting, such as interface name, or a setting
* requiring a range check is to be set via getopts_long,
@@ -669,8 +674,10 @@
* Config parameter evaluation priority order:
* 1. Any dictionary keys set in the getopt_long loop
* 2. CLI long section:key type options
- * 3. Config file (parsed last), merged with 2. and 3 - will be overwritten by CLI options
- * 4. Defaults and any rtOpts fields set in the getopt_long loop
+ * 3. Any built-in config templates
+ * 4. Any templates loaded from template file
+ * 5. Config file (parsed last), merged with 2. and 3 - will be overwritten by CLI options
+ * 6. Defaults and any rtOpts fields set in the getopt_long loop
**/
/**
@@ -726,7 +733,7 @@
*/
if( ( rtOpts->currentConfig = parseConfig(rtOpts->candidateConfig,rtOpts)) == NULL ) {
*ret = 1;
- dictionary_del(rtOpts->candidateConfig);
+ dictionary_del(&rtOpts->candidateConfig);
goto configcheck;
}
@@ -738,7 +745,7 @@
}
/* we don't need the candidate config any more */
- dictionary_del(rtOpts->candidateConfig);
+ dictionary_del(&rtOpts->candidateConfig);
/* Check network before going into background */
if(!testInterface(rtOpts->primaryIfaceName, rtOpts)) {
@@ -764,12 +771,12 @@
}
else
printf("Configuration OK\n");
- return 0;
+ goto fail;
}
/* Previous errors - exit */
if(*ret !=0)
- return 0;
+ goto fail;
/* First lock check, just to be user-friendly to the operator */
if(!rtOpts->ignore_daemon_lock) {
@@ -777,12 +784,12 @@
/* check and create Lock */
ERROR("Error: file lock failed (use -L or global:ignore_lock to ignore lock file)\n");
*ret = 3;
- return 0;
+ goto fail;
}
/* check for potential conflicts when automatic lock files are used */
if(!checkOtherLocks(rtOpts)) {
*ret = 3;
- return 0;
+ goto fail;
}
}
@@ -794,7 +801,7 @@
if (!ptpClock) {
PERROR("Error: Failed to allocate memory for protocol engine data");
*ret = 2;
- return 0;
+ goto fail;
} else {
DBG("allocated %d bytes for protocol engine data\n",
(int)sizeof(PtpClock));
@@ -808,7 +815,7 @@
"master data");
*ret = 2;
free(ptpClock);
- return 0;
+ goto fail;
} else {
DBG("allocated %d bytes for foreign master data\n",
(int)(rtOpts->max_foreign_records *
@@ -847,7 +854,7 @@
if (daemon(1,0) == -1) {
PERROR("Failed to start as daemon");
*ret = 3;
- return 0;
+ goto fail;
}
INFO(" Info: Now running as a daemon\n");
/*
@@ -869,7 +876,7 @@
if(!writeLockFile(rtOpts)){
ERROR("Error: file lock failed (use -L or global:ignore_lock to ignore lock file)\n");
*ret = 3;
- return 0;
+ goto fail;
}
}
@@ -889,7 +896,7 @@
PERROR("failed to set up event timers");
*ret = 2;
free(ptpClock);
- return 0;
+ goto fail;
}
/* establish signal handlers */
@@ -940,12 +947,15 @@
ptpClock->netPath.generalSock = -1;
ptpClock->netPath.eventSock = -1;
-
+
*ret = 0;
+
return ptpClock;
fail:
- dictionary_del(rtOpts->candidateConfig);
+ dictionary_del(&rtOpts->cliConfig);
+ dictionary_del(&rtOpts->candidateConfig);
+ dictionary_del(&rtOpts->currentConfig);
return 0;
}
Modified: trunk/src/dep/sys.c
===================================================================
--- trunk/src/dep/sys.c 2015-10-14 07:16:38 UTC (rev 591)
+++ trunk/src/dep/sys.c 2015-10-14 16:50:33 UTC (rev 592)
@@ -334,14 +334,19 @@
}
/* Write a formatted string to file pointer */
-int writeMessage(FILE* destination, int priority, const char * format, va_list ap) {
+int writeMessage(FILE* destination, uint32_t *lastHash, int priority, const char * format, va_list ap) {
+ char buf[PATH_MAX +1];
extern RunTimeOpts rtOpts;
extern Boolean startupInProgress;
int written;
char time_str[MAXTIMESTR];
struct timeval now;
+#ifndef RUNTIME_DEBUG
+ uint32_t hash;
+ va_list ap1;
+#endif /* RUNTIME_DEBUG */
extern char *translatePortState(PtpClock *ptpClock);
extern PtpClock *G_ptpClock;
@@ -355,6 +360,24 @@
(priority > LOG_WARNING)){
return 1;
}
+
+#ifndef RUNTIME_DEBUG
+ /* check if this message produces the same hash as last */
+ memset(buf, 0, sizeof(buf));
+ va_copy(ap1, ap);
+ vsnprintf(buf, PATH_MAX, format, ap1);
+ hash = fnvHash(buf, sizeof(buf), 0);
+ if(lastHash != NULL) {
+ if(format[0] != '\n' && lastHash != NULL) {
+ /* last message was the same - don't print the next one */
+ if( (lastHash != 0) && (hash == *lastHash)) {
+ return 0;
+ }
+ }
+ *lastHash = hash;
+ }
+#endif /* RUNTIME_DEBUG */
+
/* Print timestamps and prefixes only if we're running in foreground or logging to file*/
if( rtOpts.nonDaemon || destination != stderr) {
@@ -432,7 +455,7 @@
/* If we're using a log file and the message has been written OK, we're done*/
if(rtOpts.eventLog.logEnabled && rtOpts.eventLog.logFP != NULL) {
- if(writeMessage(rtOpts.eventLog.logFP, priority, format, ap) > 0) {
+ if(writeMessage(rtOpts.eventLog.logFP, &rtOpts.eventLog.lastHash, priority, format, ap) > 0) {
maintainLogSize(&rtOpts.eventLog);
if(!startupInProgress)
goto end;
@@ -472,7 +495,7 @@
std_err:
va_start(ap, format);
/* Either all else failed or we're running in foreground - or we also log to stderr */
- writeMessage(stderr, priority, format, ap);
+ writeMessage(stderr, &rtOpts.eventLog.lastHash, priority, format, ap);
end:
va_end(ap);
@@ -487,6 +510,7 @@
/* The FP is open - close it */
if(handler->logFP != NULL) {
+ handler->lastHash=0;
fclose(handler->logFP);
/*
* fclose doesn't do this at least on Linux - changes the underlying FD to -1,
Copied: trunk/src/leap-seconds.list (from rev 585, trunk/src/leap-seconds.list.28dec2015)
===================================================================
--- trunk/src/leap-seconds.list (rev 0)
+++ trunk/src/leap-seconds.list 2015-10-14 16:50:33 UTC (rev 592)
@@ -0,0 +1,249 @@
+#
+# In the following text, the symbol '#' introduces
+# a comment, which continues from that symbol until
+# the end of the line. A plain comment line has a
+# whitespace character following the comment indicator.
+# There are also special comment lines defined below.
+# A special comment will always have a non-whitespace
+# character in column 2.
+#
+# A blank line should be ignored.
+#
+# The following table shows the corrections that must
+# be applied to compute International Atomic Time (TAI)
+# from the Coordinated Universal Time (UTC) values that
+# are transmitted by almost all time services.
+#
+# The first column shows an epoch as a number of seconds
+# since 1 January 1900, 00:00:00 (1900.0 is also used to
+# indicate the same epoch.) Both of these time stamp formats
+# ignore the complexities of the time scales that were
+# used before the current definition of UTC at the start
+# of 1972. (See note 3 below.)
+# The second column shows the number of seconds that
+# must be added to UTC to compute TAI for any timestamp
+# at or after that epoch. The value on each line is
+# valid from the indicated initial instant until the
+# epoch given on the next one or indefinitely into the
+# future if there is no next line.
+# (The comment on each line shows the representation of
+# the corresponding initial epoch in the usual
+# day-month-year format. The epoch always begins at
+# 00:00:00 UTC on the indicated day. See Note 5 below.)
+#
+# Important notes:
+#
+# 1. Coordinated Universal Time (UTC) is often referred to
+# as Greenwich Mean Time (GMT). The GMT time scale is no
+# longer used, and the use of GMT to designate UTC is
+# discouraged.
+#
+# 2. The UTC time scale is realized by many national
+# laboratories and timing centers. Each laboratory
+# identifies its realization with its name: Thus
+# UTC(NIST), UTC(USNO), etc. The differences among
+# these different realizations are typically on the
+# order of a few nanoseconds (i.e., 0.000 000 00x s)
+# and can be ignored for many purposes. These differences
+# are tabulated in Circular T, which is published monthly
+# by the International Bureau of Weights and Measures
+# (BIPM). See www.bipm.org for more information.
+#
+# 3. The current definition of the relationship between UTC
+# and TAI dates from 1 January 1972. A number of different
+# time scales were in use before that epoch, and it can be
+# quite difficult to compute precise timestamps and time
+# intervals in those "prehistoric" days. For more information,
+# consult:
+#
+# The Explanatory Supplement to the Astronomical
+# Ephemeris.
+# or
+# Terry Quinn, "The BIPM and the Accurate Measurement
+# of Time," Proc. of the IEEE, Vol. 79, pp. 894-905,
+# July, 1991.
+#
+# 4. The decision to insert a leap second into UTC is currently
+# the responsibility of the International Earth Rotation and
+# Reference Systems Service. (The name was changed from the
+# International Earth Rotation Service, but the acronym IERS
+# is still used.)
+#
+# Leap seconds are announced by the IERS in its Bulletin C.
+#
+# See www.iers.org for more details.
+#
+# Every national laboratory and timing center uses the
+# data from the BIPM and the IERS to construct UTC(lab),
+# their local realization of UTC.
+#
+# Although the definition also includes the possibility
+# of dropping seconds ("negative" leap seconds), this has
+# never been done and is unlikely to be necessary in the
+# foreseeable future.
+#
+# 5. If your system keeps time as the number of seconds since
+# some epoch (e.g., NTP timestamps), then the algorithm for
+# assigning a UTC time stamp to an event that happens during a positive
+# leap second is not well defined. The official name of that leap
+# second is 23:59:60, but there is no way of representing that time
+# in these systems.
+# Many systems of this type effectively stop the system clock for
+# one second during the leap second and use a time that is equivalent
+# to 23:59:59 UTC twice. For these systems, the corresponding TAI
+# timestamp would be obtained by advancing to the next entry in the
+# following table when the time equivalent to 23:59:59 UTC
+# is used for the second time. Thus the leap second which
+# occurred on 30 June 1972 at 23:59:59 UTC would have TAI
+# timestamps computed as follows:
+#
+# ...
+# 30 June 1972 23:59:59 (2287785599, first time): TAI= UTC + 10 seconds
+# 30 June 1972 23:59:60 (2287785599,second time): TAI= UTC + 11 seconds
+# 1 July 1972 00:00:00 (2287785600) TAI= UTC + 11 seconds
+# ...
+#
+# If your system realizes the leap second by repeating 00:00:00 UTC twice
+# (this is possible but not usual), then the advance to the next entry
+# in the table must occur the second time that a time equivalent to
+# 00:00:00 UTC is used. Thus, using the same example as above:
+#
+# ...
+# 30 June 1972 23:59:59 (2287785599): TAI= UTC + 10 seconds
+# 30 June 1972 23:59:60 (2287785600, first time): TAI= UTC + 10 seconds
+# 1 July 1972 00:00:00 (2287785600,second time): TAI= UTC + 11 seconds
+# ...
+#
+# in both cases the use of timestamps based on TAI produces a smooth
+# time scale with no discontinuity in the time interval. However,
+# although the long-term behavior of the time scale is correct in both
+# methods, the second method is technically not correct because it adds
+# the extra second to the wrong day.
+#
+# This complexity would not be needed for negative leap seconds (if they
+# are ever used). The UTC time would skip 23:59:59 and advance from
+# 23:59:58 to 00:00:00 in that case. The TAI offset would decrease by
+# 1 second at the same instant. This is a much easier situation to deal
+# with, since the difficulty of unambiguously representing the epoch
+# during the leap second does not arise.
+#
+# Some systems implement leap seconds by amortizing the leap second
+# over the last few minutes of the day. The frequency of the local
+# clock is decreased (or increased) to realize the positive (or
+# negative) leap second. This method removes the time step described
+# above. Although the long-term behavior of the time scale is correct
+# in this case, this method introduces an error during the adjustment
+# period both in time and in frequency with respect to the official
+# definition of UTC.
+#
+# Questions or comments to:
+# Judah Levine
+# Time and Frequency Division
+# NIST
+# Boulder, Colorado
+# Jud...@ni...
+#
+# Last Update of leap second values: 5 January 2015
+#
+# The following line shows this last update date in NTP timestamp
+# format. This is the date on which the most recent change to
+# the leap second data was added to the file. This line can
+# be identified by the unique pair of characters in the first two
+# columns as shown below.
+#
+#$ 3629404800
+#
+# The NTP timestamps are in units of seconds since the NTP epoch,
+# which is 1 January 1900, 00:00:00. The Modified Julian Day number
+# corresponding to the NTP time stamp, X, can be computed as
+#
+# X/86400 + 15020
+#
+# where the first term converts seconds to days and the second
+# term adds the MJD corresponding to the time origin defined above.
+# The integer portion of the result is the integer MJD for that
+# day, and any remainder is the time of day, expressed as the
+# fraction of the day since 0 hours UTC. The conversion from day
+# fraction to seconds or to hours, minutes, and seconds may involve
+# rounding or truncation, depending on the method used in the
+# computation.
+#
+# The data in this file will be updated periodically as new leap
+# seconds are announced. In addition to being entered on the line
+# above, the update time (in NTP format) will be added to the basic
+# file name leap-seconds to form the name leap-seconds.<NTP TIME>.
+# In addition, the generic name leap-seconds.list will always point to
+# the most recent version of the file.
+#
+# This update procedure will be performed only when a new leap second
+# is announced.
+#
+# The following entry specifies the expiration date of the data
+# in this file in units of seconds since the origin at the instant
+# 1 January 1900, 00:00:00. This expiration date will be changed
+# at least twice per year whether or not a new leap second is
+# announced. These semi-annual changes will be made no later
+# than 1 June and 1 December of each year to indicate what
+# action (if any) is to be taken on 30 June and 31 December,
+# respectively. (These are the customary effective dates for new
+# leap seconds.) This expiration date will be identified by a
+# unique pair of characters in columns 1 and 2 as shown below.
+# In the unlikely event that a leap second is announced with an
+# effective date other than 30 June or 31 December, then this
+# file will be edited to include that leap second as soon as it is
+# announced or at least one month before the effective date
+# (whichever is later).
+# If an announcement by the IERS specifies that no leap second is
+# scheduled, then only the expiration date of the file will
+# be advanced to show that the information in the file is still
+# current -- the update time stamp, the data and the name of the file
+# will not change.
+#
+# Updated through IERS Bulletin C49
+# File expires on: 28 December 2015
+#
+#@ 3660249600
+#
+2272060800 10 # 1 Jan 1972
+2287785600 11 # 1 Jul 1972
+2303683200 12 # 1 Jan 1973
+2335219200 13 # 1 Jan 1974
+2366755200 14 # 1 Jan 1975
+2398291200 15 # 1 Jan 1976
+2429913600 16 # 1 Jan 1977
+2461449600 17 # 1 Jan 1978
+2492985600 18 # 1 Jan 1979
+2524521600 19 # 1 Jan 1980
+2571782400 20 # 1 Jul 1981
+2603318400 21 # 1 Jul 1982
+2634854400 22 # 1 Jul 1983
+2698012800 23 # 1 Jul 1985
+2776982400 24 # 1 Jan 1988
+2840140800 25 # 1 Jan 1990
+2871676800 26 # 1 Jan 1991
+2918937600 27 # 1 Jul 1992
+2950473600 28 # 1 Jul 1993
+2982009600 29 # 1 Jul 1994
+3029443200 30 # 1 Jan 1996
+3076704000 31 # 1 Jul 1997
+3124137600 32 # 1 Jan 1999
+3345062400 33 # 1 Jan 2006
+3439756800 34 # 1 Jan 2009
+3550089600 35 # 1 Jul 2012
+3644697600 36 # 1 Jul 2015
+#
+# the following special comment contains the
+# hash value of the data in this file computed
+# use the secure hash algorithm as specified
+# by FIPS 180-1. See the files in ~/pub/sha for
+# the details of how this hash value is
+# computed. Note that the hash computation
+# ignores comments and whitespace characters
+# in data lines. It includes the NTP values
+# of both the last modification time and the
+# expiration time of the file, but not the
+# white space on those lines.
+# the hash line is also ignored in the
+# computation.
+#
+#h 45e70fa7 a9df2033 f4a49ab0 ec648273 7b6c22c
\ No newline at end of file
Deleted: trunk/src/leap-seconds.list.28dec2015
===================================================================
--- trunk/src/leap-seconds.list.28dec2015 2015-10-14 07:16:38 UTC (rev 591)
+++ trunk/src/leap-seconds.list.28dec2015 2015-10-14 16:50:33 UTC (rev 592)
@@ -1,249 +0,0 @@
-#
-# In the following text, the symbol '#' introduces
-# a comment, which continues from that symbol until
-# the end of the line. A plain comment line has a
-# whitespace character following the comment indicator.
-# There are also special comment lines defined below.
-# A special comment will always have a non-whitespace
-# character in column 2.
-#
-# A blank line should be ignored.
-#
-# The following table shows the corrections that must
-# be applied to compute International Atomic Time (TAI)
-# from the Coordinated Universal Time (UTC) values that
-# are transmitted by almost all time services.
-#
-# The first column shows an epoch as a number of seconds
-# since 1 January 1900, 00:00:00 (1900.0 is also used to
-# indicate the same epoch.) Both of these time stamp formats
-# ignore the complexities of the time scales that were
-# used before the current definition of UTC at the start
-# of 1972. (See note 3 below.)
-# The second column shows the number of seconds that
-# must be added to UTC to compute TAI for any timestamp
-# at or after that epoch. The value on each line is
-# valid from the indicated initial instant until the
-# epoch given on the next one or indefinitely into the
-# future if there is no next line.
-# (The comment on each line shows the representation of
-# the corresponding initial epoch in the usual
-# day-month-year format. The epoch always begins at
-# 00:00:00 UTC on the indicated day. See Note 5 below.)
-#
-# Important notes:
-#
-# 1. Coordinated Universal Time (UTC) is often referred to
-# as Greenwich Mean Time (GMT). The GMT time scale is no
-# longer used, and the use of GMT to designate UTC is
-# discouraged.
-#
-# 2. The UTC time scale is realized by many national
-# laboratories and timing centers. Each laboratory
-# identifies its realization with its name: Thus
-# UTC(NIST), UTC(USNO), etc. The differences among
-# these different realizations are typically on the
-# order of a few nanoseconds (i.e., 0.000 000 00x s)
-# and can be ignored for many purposes. These differences
-# are tabulated in Circular T, which is published monthly
-# by the International Bureau of Weights and Measures
-# (BIPM). See www.bipm.org for more information.
-#
-# 3. The current definition of the relationship between UTC
-# and TAI dates from 1 January 1972. A number of different
-# time scales were in use before that epoch, and it can be
-# quite difficult to compute precise timestamps and time
-# intervals in those "prehistoric" days. For more information,
-# consult:
-#
-# The Explanatory Supplement to the Astronomical
-# Ephemeris.
-# or
-# Terry Quinn, "The BIPM and the Accurate Measurement
-# of Time," Proc. of the IEEE, Vol. 79, pp. 894-905,
-# July, 1991.
-#
-# 4. The decision to insert a leap second into UTC is currently
-# the responsibility of the International Earth Rotation and
-# Reference Systems Service. (The name was changed from the
-# International Earth Rotation Service, but the acronym IERS
-# is still used.)
-#
-# Leap seconds are announced by the IERS in its Bulletin C.
-#
-# See www.iers.org for more details.
-#
-# Every national laboratory and timing center uses the
-# data from the BIPM and the IERS to construct UTC(lab),
-# their local realization of UTC.
-#
-# Although the definition also includes the possibility
-# of dropping seconds ("negative" leap seconds), this has
-# never been done and is unlikely to be necessary in the
-# foreseeable future.
-#
-# 5. If your system keeps time as the number of seconds since
-# some epoch (e.g., NTP timestamps), then the algorithm for
-# assigning a UTC time stamp to an event that happens during a positive
-# leap second is not well defined. The official name of that leap
-# second is 23:59:60, but there is no way of representing that time
-# in these systems.
-# Many systems of this type effectively stop the system clock for
-# one second during the leap second and use a time that is equivalent
-# to 23:59:59 UTC twice. For these systems, the corresponding TAI
-# timestamp would be obtained by advancing to the next entry in the
-# following table when the time equivalent to 23:59:59 UTC
-# is used for the second time. Thus the leap second which
-# occurred on 30 June 1972 at 23:59:59 UTC would have TAI
-# timestamps computed as follows:
-#
-# ...
-# 30 June 1972 23:59:59 (2287785599, first time): TAI= UTC + 10 seconds
-# 30 June 1972 23:59:60 (2287785599,second time): TAI= UTC + 11 seconds
-# 1 July 1972 00:00:00 (2287785600) TAI= UTC + 11 seconds
-# ...
-#
-# If your system realizes the leap second by repeating 00:00:00 UTC twice
-# (this is possible but not usual), then the advance to the next entry
-# in the table must occur the second time that a time equivalent to
-# 00:00:00 UTC is used. Thus, using the same example as above:
-#
-# ...
-# 30 June 1972 23:59:59 (2287785599): TAI= UTC + 10 seconds
-# 30 June 1972 23:59:60 (2287785600, first time): TAI= UTC + 10 seconds
-# 1 July 1972 00:00:00 (2287785600,second time): TAI= UTC + 11 seconds
-# ...
-#
-# in both cases the use of timestamps based on TAI produces a smooth
-# time scale with no discontinuity in the time interval. However,
-# although the long-term behavior of the time scale is correct in both
-# methods, the second method is technically not correct because it adds
-# the extra second to the wrong day.
-#
-# This complexity would not be needed for negative leap seconds (if they
-# are ever used). The UTC time would skip 23:59:59 and advance from
-# 23:59:58 to 00:00:00 in that case. The TAI offset would decrease by
-# 1 second at the same instant. This is a much easier situation to deal
-# with, since the difficulty of unambiguously representing the epoch
-# during the leap second does not arise.
-#
-# Some systems implement leap seconds by amortizing the leap second
-# over the last few minutes of the day. The frequency of the local
-# clock is decreased (or increased) to realize the positive (or
-# negative) leap second. This method removes the time step described
-# above. Although the long-term behavior of the time scale is correct
-# in this case, this method introduces an error during the adjustment
-# period both in time and in frequency with respect to the official
-# definition of UTC.
-#
-# Questions or comments to:
-# Judah Levine
-# Time and Frequency Division
-# NIST
-# Boulder, Colorado
-# Jud...@ni...
-#
-# Last Update of leap second values: 5 January 2015
-#
-# The following line shows this last update date in NTP timestamp
-# format. This is the date on which the most recent change to
-# the leap second data was added to the file. This line can
-# be identified by the unique pair of characters in the first two
-# columns as shown below.
-#
-#$ 3629404800
-#
-# The NTP timestamps are in units of seconds since the NTP epoch,
-# which is 1 January 1900, 00:00:00. The Modified Julian Day number
-# corresponding to the NTP time stamp, X, can be computed as
-#
-# X/86400 + 15020
-#
-# where the first term converts seconds to days and the second
-# term adds the MJD corresponding to the time origin defined above.
-# The integer portion of the result is the integer MJD for that
-# day, and any remainder is the time of day, expressed as the
-# fraction of the day since 0 hours UTC. The conversion from day
-# fraction to seconds or to hours, minutes, and seconds may involve
-# rounding or truncation, depending on the method used in the
-# computation.
-#
-# The data in this file will be updated periodically as new leap
-# seconds are announced. In addition to being entered on the line
-# above, the update time (in NTP format) will be added to the basic
-# file name leap-seconds to form the name leap-seconds.<NTP TIME>.
-# In addition, the generic name leap-seconds.list will always point to
-# the most recent version of the file.
-#
-# This update procedure will be performed only when a new leap second
-# is announced.
-#
-# The following entry specifies the expiration date of the data
-# in this file in units of seconds since the origin at the instant
-# 1 January 1900, 00:00:00. This expiration date will be changed
-# at least twice per year whether or not a new leap second is
-# announced. These semi-annual changes will be made no later
-# than 1 June and 1 December of each year to indicate what
-# action (if any) is to be taken on 30 June and 31 December,
-# respectively. (These are the customary effective dates for new
-# leap seconds.) This expiration date will be identified by a
-# unique pair of characters in columns 1 and 2 as shown below.
-# In the unlikely event that a leap second is announced with an
-# effective date other than 30 June or 31 December, then this
-# file will be edited to include that leap second as soon as it is
-# announced or at least one month before the effective date
-# (whichever is later).
-# If an announcement by the IERS specifies that no leap second is
-# scheduled, then only the expiration date of the file will
-# be advanced to show that the information in the file is still
-# current -- the update time stamp, the data and the name of the file
-# will not change.
-#
-# Updated through IERS Bulletin C49
-# File expires on: 28 December 2015
-#
-#@ 3660249600
-#
-2272060800 10 # 1 Jan 1972
-2287785600 11 # 1 Jul 1972
-2303683200 12 # 1 Jan 1973
-2335219200 13 # 1 Jan 1974
-2366755200 14 # 1 Jan 1975
-2398291200 15 # 1 Jan 1976
-2429913600 16 # 1 Jan 1977
-2461449600 17 # 1 Jan 1978
-2492985600 18 # 1 Jan 1979
-2524521600 19 # 1 Jan 1980
-2571782400 20 # 1 Jul 1981
-2603318400 21 # 1 Jul 1982
-2634854400 22 # 1 Jul 1983
-2698012800 23 # 1 Jul 1985
-2776982400 24 # 1 Jan 1988
-2840140800 25 # 1 Jan 1990
-2871676800 26 # 1 Jan 1991
-2918937600 27 # 1 Jul 1992
-2950473600 28 # 1 Jul 1993
-2982009600 29 # 1 Jul 1994
-3029443200 30 # 1 Jan 1996
-3076704000 31 # 1 Jul 1997
-3124137600 32 # 1 Jan 1999
-3345062400 33 # 1 Jan 2006
-3439756800 34 # 1 Jan 2009
-3550089600 35 # 1 Jul 2012
-3644697600 36 # 1 Jul 2015
-#
-# the following special comment contains the
-# hash value of the data in this file computed
-# use the secure hash algorithm as specified
-# by FIPS 180-1. See the files in ~/pub/sha for
-# the details of how this hash value is
-# computed. Note that the hash computation
-# ignores comments and whitespace characters
-# in data lines. It includes the NTP values
-# of both the last modification time and the
-# expiration time of the file, but not the
-# white space on those lines.
-# the hash line is also ignored in the
-# computation.
-#
-#h 45e70fa7 a9df2033 f4a49ab0 ec648273 7b6c22c
\ No newline at end of file
Modified: trunk/src/protocol.c
===================================================================
--- trunk/src/protocol.c 2015-10-14 07:16:38 UTC (rev 591)
+++ trunk/src/protocol.c 2015-10-14 16:50:33 UTC (rev 592)
@@ -686,7 +686,7 @@
UInteger8 state;
ptpClock->message_activity = FALSE;
-
+
/* Process record_update (BMC algorithm) before everything else */
switch (ptpClock->portState)
{
Modified: trunk/src/ptpd.h
===================================================================
--- trunk/src/ptpd.h 2015-10-14 07:16:38 UTC (rev 591)
+++ trunk/src/ptpd.h 2015-10-14 16:50:33 UTC (rev 592)
@@ -186,6 +186,12 @@
exit(1); \
}
+#define SAFE_FREE(pointer) \
+ if(pointer != NULL) { \
+ free(pointer); \
+ pointer = NULL; \
+ }
+
#define IS_SET(data, bitpos) \
((data & ( 0x1 << bitpos )) == (0x1 << bitpos))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|