- Introduced a new trace facility

- Fixed performance problems in many protocol drivers.
This commit is contained in:
koennecke
2011-06-29 07:53:54 +00:00
parent 30fa6e9081
commit 8162f117bd
5 changed files with 38 additions and 3 deletions

View File

@@ -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: