From f16b63da0b52bb7c6cb9a57f4c830aeb5f074e14 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Thu, 26 Aug 1999 21:36:39 +0000 Subject: [PATCH] fixed bug where time sync UDP client was getting in a state where it was using the response from the previous request, and ending up setting the time 10 seconds back --- src/db/drvTS.c | 24 ++++++++++++++++++++++++ src/vxWorks/db/drvTS.c | 24 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/db/drvTS.c b/src/db/drvTS.c index 30c4c83e7..f683efc44 100644 --- a/src/db/drvTS.c +++ b/src/db/drvTS.c @@ -13,6 +13,9 @@ /* * $Log$ + * Revision 1.30 1999/08/05 21:50:21 jhill + * global reformat + * * Revision 1.29 1999/02/11 17:02:34 jhill * removed potential infinite recursion from tsForceSoftSync() * @@ -1830,6 +1833,27 @@ static long TSgetData(char* buf, int buf_size, int soc, struct timeval timeOut; struct timespec send_time,recv_time; + /* + * joh 08-26-99 + * added this code which removes responses laying around from + * requests made in the past that timed out + */ + Debug(8,"removing stale responses %s\n", ""); + while (1) { + int status; + + status = ioctl (soc, FIONREAD, (int) &mlen); + if (status<0) { + Debug(1,"ioctl FIONREAD failed because \"%s\"?\n", strerror(errno)); + break; + } + else if (mlen==0) { + break; + } + Debug(1,"removing stale response of %d bytes\n", mlen); + recvfrom(soc,buf,buf_size,0,from_sin,&flen); + } + /* convert millisecond time out to seconds/microseconds */ s=TSdata.time_out/1000; us=(TSdata.time_out-(s*1000))*1000; Debug(6,"time_out Second=%lu\n",s); diff --git a/src/vxWorks/db/drvTS.c b/src/vxWorks/db/drvTS.c index 30c4c83e7..f683efc44 100644 --- a/src/vxWorks/db/drvTS.c +++ b/src/vxWorks/db/drvTS.c @@ -13,6 +13,9 @@ /* * $Log$ + * Revision 1.30 1999/08/05 21:50:21 jhill + * global reformat + * * Revision 1.29 1999/02/11 17:02:34 jhill * removed potential infinite recursion from tsForceSoftSync() * @@ -1830,6 +1833,27 @@ static long TSgetData(char* buf, int buf_size, int soc, struct timeval timeOut; struct timespec send_time,recv_time; + /* + * joh 08-26-99 + * added this code which removes responses laying around from + * requests made in the past that timed out + */ + Debug(8,"removing stale responses %s\n", ""); + while (1) { + int status; + + status = ioctl (soc, FIONREAD, (int) &mlen); + if (status<0) { + Debug(1,"ioctl FIONREAD failed because \"%s\"?\n", strerror(errno)); + break; + } + else if (mlen==0) { + break; + } + Debug(1,"removing stale response of %d bytes\n", mlen); + recvfrom(soc,buf,buf_size,0,from_sin,&flen); + } + /* convert millisecond time out to seconds/microseconds */ s=TSdata.time_out/1000; us=(TSdata.time_out-(s*1000))*1000; Debug(6,"time_out Second=%lu\n",s);