bug fixes and enhancements related to evcontroller

SKIPPED:
	psi/dilludriv.c
	psi/el755driv.c
	psi/eurodriv.c
	psi/eve.c
	psi/eve.h
	psi/fsm.c
	psi/ipsdriv.c
	psi/itc4driv.c
	psi/itcdriv.c
	psi/lcdriv.c
	psi/logger.c
	psi/logger.h
	psi/slsmagnet.c
This commit is contained in:
zolliker
2005-03-03 14:13:06 +00:00
parent c7bef62242
commit d393a0a357
10 changed files with 118 additions and 44 deletions

View File

@ -54,6 +54,10 @@
#define SOCKET 2
#define UDP 3
/* wait time [ms] between a close and the next open */
#define WAIT_CLOSE_OPEN 500
struct timeval lastclose={-1,0};
/*-----------------------------------------------------------------------
Redefine this function if another means of error reporting is necessary.
*/
@ -216,10 +220,12 @@ CreateSocketAdress(
mkChannel *NETConnect(char *name, int port)
{
mkChannel *pRes = NULL;
int iRet, i;
int iRet, i, cnt;
char pBueffel[80];
struct hostent *pServer = NULL;
struct linger lili;
struct timeval now;
long dif;
assert(port > 0);
@ -248,9 +254,18 @@ CreateSocketAdress(
free(pRes);
return NULL;
}
if (lastclose.tv_sec >= 0) {
gettimeofday(&now, NULL);
dif = (now.tv_sec-lastclose.tv_sec)*1000+(now.tv_usec-lastclose.tv_usec)/1000;
if (dif < 0) dif += 24*3600*1000;
} else {
dif = 0;
}
if (dif < WAIT_CLOSE_OPEN) {
usleep((WAIT_CLOSE_OPEN-dif)*1000);
}
iRet = connect(pRes->sockid,(struct sockaddr *)&(pRes->adresse),
sizeof(struct sockaddr_in));
if(iRet < 0)
{
free(pRes);
@ -518,7 +533,7 @@ int NETReadTillTermNew(mkChannel *self, long timeout,
{
gettimeofday(&now, NULL);
dif = (now.tv_sec-start.tv_sec)*1000+(now.tv_usec-start.tv_usec)/1000;
if (dif < 0) dif += 24*3600*1000; /* treat midnight correctly */
if(dif > timeout)
{
return 0; /* timeout */
@ -621,6 +636,7 @@ This old version may be removed in some stage. It has two problems:
}
iRet = close(self->sockid);
gettimeofday(&lastclose, NULL);
self->iType = 0;
self->sockid = 0;
if(iRet < 0)