--- ntp-4.2.4p3/ntpd/refclock_shm.c 2007-10-27 12:25:30.000000000 +0100 +++ ntp-4.2.4p3+byte/ntpd/refclock_shm.c 2007-10-27 13:12:57.000000000 +0100 @@ -84,9 +84,10 @@ int leap; int precision; int nsamples; int valid; - int dummy[10]; + uint32_t refid; + char dummy[sizeof(int) * 10 - sizeof(uint32_t)]; }; struct shmTime *getShmTime(int); @@ -95,9 +96,9 @@ int shmid=0; assert (unit<10); /* MAXUNIT is 4, so should never happen */ shmid=shmget (0x4e545030+unit, sizeof (struct shmTime), - IPC_CREAT|(unit<2?0700:0777)); + IPC_CREAT|0700); if (shmid==-1) { /*error */ msyslog(LOG_ERR,"SHM shmget (unit %d): %s",unit,strerror(errno)); return 0; } @@ -178,8 +179,9 @@ ((struct shmTime*)pp->unitptr)->precision=PRECISION; peer->precision = ((struct shmTime*)pp->unitptr)->precision; ((struct shmTime*)pp->unitptr)->valid=0; ((struct shmTime*)pp->unitptr)->nsamples=NSAMPLES; + ((struct shmTime*)pp->unitptr)->refid=0; pp->clockdesc = DESCRIPTION; return (1); } else { @@ -242,8 +244,9 @@ if (up->valid) { struct timeval tvr; struct timeval tvt; struct tm *t; + uint32_t refid=0; int ok=1; tvr.tv_sec = 0; tvr.tv_usec = 0; tvt.tv_sec = 0; @@ -257,12 +260,15 @@ } break; case 1: { int cnt=up->count; +__asm__ __volatile__ ("":::"memory"); tvr.tv_sec=up->receiveTimeStampSec; tvr.tv_usec=up->receiveTimeStampUSec; tvt.tv_sec=up->clockTimeStampSec; tvt.tv_usec=up->clockTimeStampUSec; + refid=up->refid; +__asm__ __volatile__ ("":::"memory"); ok=(cnt==up->count); } break; default: @@ -284,8 +290,10 @@ pp->second=t->tm_sec; pp->nsec=tvt.tv_usec * 1000; peer->precision=up->precision; pp->leap=up->leap; + if (refid != 0) + peer->refid = pp->refid = refid; } else { refclock_report(peer, CEVNT_FAULT); msyslog (LOG_NOTICE, "SHM: access clash in shared memory");