- Introduced a new trace facility
- Fixed performance problems in many protocol drivers.
This commit is contained in:
19
pmacprot.c
19
pmacprot.c
@@ -16,6 +16,10 @@
|
||||
* copyright: see file COPYRIGHT
|
||||
*
|
||||
* Mark Koennecke, December 2008
|
||||
*
|
||||
* Introduced a delay on read in order to throttle requests
|
||||
*
|
||||
* Mark Koennecke, June 2011
|
||||
*/
|
||||
#include <errno.h>
|
||||
#include <ascon.h>
|
||||
@@ -79,8 +83,12 @@ typedef struct {
|
||||
char *ptr;
|
||||
int bytesToWrite;
|
||||
int expectACK;
|
||||
double startTime;
|
||||
} PMACPrivate, *pPMACPrivate;
|
||||
|
||||
/*---------------------------------------------------------------------------*
|
||||
* wait period before read
|
||||
----------------------------------------------------------------------------*/
|
||||
#define READDELAY .05
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static int PMACHandler(Ascon * a)
|
||||
{
|
||||
@@ -123,11 +131,19 @@ static int PMACHandler(Ascon * a)
|
||||
a->wrPos += ret;
|
||||
if (a->wrPos >= priv->bytesToWrite) {
|
||||
a->state = AsconWriteDone;
|
||||
priv->startTime = DoubleTime();
|
||||
} else {
|
||||
priv->ptr += ret;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case AsconReadStart:
|
||||
DynStringClear(a->rdBuffer);
|
||||
if(DoubleTime() > priv->startTime + READDELAY){
|
||||
a->start = DoubleTime();
|
||||
a->state = AsconReading;
|
||||
}
|
||||
break;
|
||||
case AsconReading:
|
||||
ret = AsconReadChar(a->fd, &chr);
|
||||
if (ret < 0) {
|
||||
@@ -166,6 +182,7 @@ static int PMACHandler(Ascon * a)
|
||||
a->state = AsconTimeout;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user