{
recvbuf_t *rbuf;
- if (0 == full_recvbufs)
- return 0;
-
+ LOCK();
#ifdef DEBUG
if (debug > 1 && full_recvbufs)
printf("get_full_recv_buffer() called and full_recvbufs is %lu\n", full_recvbufs);
#endif
- if (0 == full_recvbufs)
- msyslog(LOG_ERR, "get_full_recv_buffer() called but full_recvbufs is 0!");
- LOCK();
rbuf = ISC_LIST_HEAD(full_list);
if (rbuf != NULL)
{
}
else
{
- if (full_recvbufs)
+ if (full_recvbufs) {
msyslog(LOG_ERR, "get_full_recv_buffer: full_list is empty but full_recvbufs is %lu!", full_recvbufs);
- /*
- * Make sure we reset the full count to 0
- */
- full_recvbufs = 0;
+ abort();
+ }
}
UNLOCK();
return (rbuf);
block_io_and_alarm();
# endif
- tot_full_recvbufs = full_recvbuffs(); /* get received buffers */
if (alarm_flag) /* alarmed? */
{
was_alarmed = 1;
alarm_flag = 0;
}
- if (!was_alarmed && tot_full_recvbufs == 0)
+ if (!was_alarmed && has_full_recv_buffer() == ISC_FALSE)
{
/*
* Nothing to do. Wait for something.
was_alarmed = 1;
alarm_flag = 0;
}
- tot_full_recvbufs = full_recvbuffs(); /* get received buffers */
}
-# ifdef HAVE_SIGNALED_IO
- unblock_io_and_alarm();
-# endif /* HAVE_SIGNALED_IO */
- /*
- * Out here, signals are unblocked. Call timer routine
- * to process expiry.
- */
if (was_alarmed)
{
+# ifdef HAVE_SIGNALED_IO
+ unblock_io_and_alarm();
+# endif /* HAVE_SIGNALED_IO */
+ /*
+ * Out here, signals are unblocked. Call timer routine
+ * to process expiry.
+ */
timer();
was_alarmed = 0;
+# ifdef HAVE_SIGNALED_IO
+ block_io_and_alarm();
+# endif /* HAVE_SIGNALED_IO */
}
#endif /* HAVE_IO_COMPLETION_PORT */
- while (full_recvbuffs())
+ rbuf = get_full_recv_buffer();
+ while (rbuf != NULL)
{
+# ifdef HAVE_SIGNALED_IO
+ unblock_io_and_alarm();
+# endif /* HAVE_SIGNALED_IO */
/*
* Call the data procedure to handle each received
* packet.
*/
- rbuf = get_full_recv_buffer();
if (rbuf != NULL) /* This should always be true */
{
(rbuf->receiver)(rbuf);
freerecvbuf(rbuf);
+ } else {
+ msyslog(LOG_ERR, "receive buffer corruption - receiver found to be NULL - ABORTING");
+ abort();
}
+# ifdef HAVE_SIGNALED_IO
+ block_io_and_alarm();
+# endif /* HAVE_SIGNALED_IO */
}
/*
* Go around again
*/
}
+# ifdef HAVE_SIGNALED_IO
+ unblock_io_and_alarm();
+# endif /* HAVE_SIGNALED_IO */
return 1;
}
/*
- * /src/NTP/REPOSITORY/ntp4-dev/ntpd/refclock_parse.c,v 4.66 2006/03/18 00:45:30 kardel RELEASE_20060318_A
+ * /src/NTP/REPOSITORY/ntp4-dev/ntpd/refclock_parse.c,v 4.68 2006/05/01 17:02:51 kardel RELEASE_20060501_A
*
- * refclock_parse.c,v 4.66 2006/03/18 00:45:30 kardel RELEASE_20060318_A
+ * refclock_parse.c,v 4.68 2006/05/01 17:02:51 kardel RELEASE_20060501_A
*
* generic reference clock driver for several DCF/GPS/MSF/... receivers
*
#include "binio.h"
#include "ascii.h"
#include "ieee754io.h"
+#include "recvbuff.h"
-static char rcsid[] = "refclock_parse.c,v 4.66 2006/03/18 00:45:30 kardel RELEASE_20060318_A";
+static char rcsid[] = "refclock_parse.c,v 4.68 2006/05/01 17:02:51 kardel RELEASE_20060501_A";
/**===========================================================================
** external interface to ntp mechanism
{
if (parse_ioread(&parse->parseio, (unsigned int)(*s++), &ts))
{
- struct recvbuf buf;
+ struct recvbuf *buf;
/*
* got something good to eat
#endif /* TIOCDCDTIMESTAMP */
#endif /* HAVE_PPSAPI */
}
- if (count)
- { /* simulate receive */
- memmove((caddr_t)buf.recv_buffer,
- (caddr_t)&parse->parseio.parse_dtime,
- sizeof(parsetime_t));
- parse_iodone(&parse->parseio);
- buf.recv_length = sizeof(parsetime_t);
- buf.recv_time = rbufp->recv_time;
- buf.srcadr = rbufp->srcadr;
- buf.dstadr = rbufp->dstadr;
- buf.fd = rbufp->fd;
- buf.X_from_where = rbufp->X_from_where;
- rbufp->receiver(&buf);
- }
+
+ if (count)
+ { /* simulate receive */
+ buf = get_free_recv_buffer();
+ if (buf != NULL) {
+ memmove((caddr_t)buf->recv_buffer,
+ (caddr_t)&parse->parseio.parse_dtime,
+ sizeof(parsetime_t));
+ buf->recv_length = sizeof(parsetime_t);
+ buf->recv_time = rbufp->recv_time;
+ buf->srcadr = rbufp->srcadr;
+ buf->dstadr = rbufp->dstadr;
+ buf->receiver = rbufp->receiver;
+ buf->fd = rbufp->fd;
+ buf->X_from_where = rbufp->X_from_where;
+ add_full_recv_buffer(buf);
+ }
+ parse_iodone(&parse->parseio);
+ }
else
{
memmove((caddr_t)rbufp->recv_buffer,
* History:
*
* refclock_parse.c,v
+ * Revision 4.68 2006/05/01 17:02:51 kardel
+ * copy receiver method also for newlwy created receive buffers
+ *
+ * Revision 4.67 2006/05/01 14:37:29 kardel
+ * If an input buffer parses into more than one message do insert the
+ * parsed message in a new input buffer instead of processing it
+ * directly. This avoids deed complicated processing in signal
+ * handling.
+ *
* Revision 4.66 2006/03/18 00:45:30 kardel
* coverity fixes found in NetBSD coverity scan
*