Files
epics-base/src/ca/flow_control.c
1994-03-30 11:29:35 +00:00

134 lines
2.8 KiB
C
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/************************************************************************/
/* */
/* L O S A L A M O S */
/* Los Alamos National Laboratory */
/* Los Alamos, New Mexico 87545 */
/* */
/* Copyright, 1986, The Regents of the University of California. */
/* */
/* */
/* History */
/* ------- */
/* 06xx89 joh First Release */
/* 060591 joh delinting */
/* */
/*_begin */
/************************************************************************/
/* */
/* Title: IOC network flow control module */
/* File: atcs:[ca]flow_control.c */
/* Environment: VMS. UNIX, VRTX */
/* Equipment: VAX, SUN, VME */
/* */
/* */
/* Purpose */
/* ------- */
/* */
/* ioc flow control module */
/* */
/* */
/* Special comments */
/* ------- -------- */
/* */
/************************************************************************/
/*_end */
static char *sccsId = "$Id$";
#if defined(vxWorks)
# include <vxWorks.h>
# include <ioLib.h>
# include <socket.h>
# include <ioctl.h>
#else
# if defined(VMS)
# include <sys/types.h>
# include <sys/socket.h>
# if defined(UCX) /* GeG 09-DEC-1992 */
# include <sys/ucx$inetdef.h>
# include <ucx.h>
# else
# include <sys/ioctl.h>
# endif
# else
# if defined(UNIX)
# include <sys/types.h>
# include <sys/socket.h>
# include <sys/ioctl.h>
# else
@@@@ dont compile @@@@
# endif
# endif
#endif
#include <os_depen.h>
#include <cadef.h>
#include <iocmsg.h>
#include <iocinf.h>
/*
* FLOW CONTROL
*
* Keep track of how many times messages have
* come with out a break in between and
* suppress monitors if we are behind
* (an update is sent when we catch up)
*/
#ifdef __STDC__
void flow_control(struct ioc_in_use *piiu)
#else
void flow_control(piiu)
struct ioc_in_use *piiu;
#endif
{
unsigned nbytes;
register int status;
register int busy = piiu->client_busy;
LOCK;
/*
* use of the additional system call here does not
* seem to slow things down appreciably
*/
status = socket_ioctl(piiu->sock_chan,
FIONREAD,
(int)&nbytes);
if (status < 0) {
piiu->conn_up = FALSE;
UNLOCK;
return;
}
/*
* I wish to avoid going into flow control however
* as this impacts the performance of batched fetches
*/
if (nbytes) {
piiu->contiguous_msg_count++;
if (!busy)
if (piiu->contiguous_msg_count >
MAX_CONTIGUOUS_MSG_COUNT) {
piiu->client_busy = TRUE;
ca_busy_message(piiu);
# ifdef DEBUG
printf("fc on\n");
# endif
}
} else {
piiu->contiguous_msg_count = 0;
if (busy) {
# ifdef DEBUG
printf("fc off\n");
# endif
ca_ready_message(piiu);
piiu->client_busy = FALSE;
}
}
UNLOCK;
return;
}