Merge RTEMS NTP fix from 3.14 branch, to revno 12615

This commit is contained in:
Andrew Johnson
2016-02-29 17:49:08 -06:00
2 changed files with 44 additions and 0 deletions
+12
View File
@@ -14,6 +14,14 @@
<h2 align="center">Changes between 3.15.3 and 3.15.4</h2>
<!-- Insert new items immediately below here ... -->
<h3>RTEMS NTP Support Issue</h3>
<p>On RTEMS the NTP Time Provider could in some circumstances get out of sync
with the server because the osdNTPGet() code wasn't clearing its input socket
before sending out a new request. This
(<a href="https://bugs.launchpad.net/bugs/1549908">Launchpad bug 1549908</a>)
has now been fixed.</p>
<h3>CA server configuration changes</h3>
<p>RSRV now honors EPICS_CAS_INTF_ADDR_LIST and binds only to the provided list
@@ -49,7 +57,11 @@ back-porting some earlier changes from the 3.15 branch, and fixes
<a href="https://code.launchpad.net/bugs/1514520">Launchpad bug
#1514520</a>.</p>
<<<<<<< TREE
<h3>Fix <tt>ipAddrToAsciiAsync()</tt>: don't try to join the daemon thread</h3>
=======
<h3>ipAddrToAsciiAsync.: Don't try to join the daemon thread</h3>
>>>>>>> MERGE-SOURCE
<p>On process exit, don't try to stop the worker thread that makes DNS lookups
asynchronous. Previously this would wait for any lookups still in progress,
+32
View File
@@ -10,6 +10,9 @@
*
* Author: W. Eric Norum
*/
#define __BSD_VISIBLE 1
#include <sys/types.h>
#include <sys/socket.h>
#include <epicsStdio.h>
#include <rtems.h>
@@ -40,8 +43,37 @@ void osdTimeRegister(void)
int osdNTPGet(struct timespec *ts)
{
static unsigned bequiet;
ssize_t ret;
if (ntpSocket < 0)
return -1;
/* rtems_bsdnet_get_ntp() will send an NTP request, then
* call recvfrom() exactly once to process the expected reply.
* Any leftovers in the socket buffer (ie. duplicates of
* previous replies) will cause problems.
* So flush out the socket buffer first.
*/
do {
char junk[16];
ret = recvfrom(ntpSocket, junk, sizeof(junk), MSG_DONTWAIT, NULL, NULL);
if (ret == -1 && errno == EAGAIN) {
break;
}
else if (ret == -1) {
if (!bequiet) {
printf("osdNTPGet cleaner error: %s\n", strerror(errno));
bequiet = 1;
}
break;
}
else {
bequiet = 0;
}
} while (ret > 0);
return rtems_bsdnet_get_ntp(ntpSocket, NULL, ts);
}