- fixed a anticollider bug

- fixed problems with the synchronization code
- fixed some small TASP problems
This commit is contained in:
cvs
2003-04-22 09:29:13 +00:00
parent cb4bbbc93c
commit b06a473cf5
9 changed files with 151 additions and 13 deletions

View File

@@ -19,7 +19,7 @@
/*-----------------------------------------------------------------------
Some file statics which hold the connection parameters
------------------------------------------------------------------------*/
static char *hostname, *looser, *password;
static char *hostname, *looser, *password, *syncFile;
static int port;
static mkChannel *connection = NULL;
/*-----------------------------------------------------------------------*/
@@ -95,6 +95,8 @@ static void killSync(void *pData)
free(looser);
if(password)
free(password);
if(syncFile)
free(syncFile);
}
/*----------------------------------------------------------------------*/
int MakeSync(SConnection *pCon, SicsInterp *pSics, void *pData,
@@ -120,6 +122,14 @@ int MakeSync(SConnection *pCon, SicsInterp *pSics, void *pData,
port = atof(argv[2]);
looser = strdup(argv[3]);
password = strdup(argv[4]);
if(argc > 5)
{
syncFile = strdup(argv[5]);
}
else
{
syncFile = NULL;
}
pServ->simMode = 1;
/*
@@ -164,7 +174,14 @@ int Synchronize(SConnection *pCon, SicsInterp *pSics, void *pData,
first tell the remote server to backup
*/
SetStatusFixed(eBatch);
strcpy(pBueffel,"transact backup\n");
strcpy(pBueffel,"transact backup");
if(syncFile != NULL)
{
strcat(pBueffel," ");
strcat(pBueffel,syncFile);
}
strcat(pBueffel,"\n");
test = NETWrite(connection,pBueffel,strlen(pBueffel));
if(test != 1)
{
@@ -177,11 +194,15 @@ int Synchronize(SConnection *pCon, SicsInterp *pSics, void *pData,
return 0;
}
/*
wait 10 seconds for correct message
wait 60 seconds for correct message
*/
pServ->simMode = 0; /* bug fix: SicsWait returns right away if this would be
left at normal. Reset after loop
*/
pBueffel[0] = '\0';
for(i = 0; i < 10; i++)
for(i = 0; i < 60; i++)
{
pRead[0] = '\0';
test = NETRead(connection,pRead,75,20*1000);
if(test < 0)
{
@@ -192,13 +213,17 @@ int Synchronize(SConnection *pCon, SicsInterp *pSics, void *pData,
SCWrite(pCon,
"Try again in order to reconnect before giving up",eWarning);
ClearFixedStatus(eEager);
pServ->simMode = 1;
return 0;
}
else
{
strcat(pBueffel,pRead);
if(test > 0)
{
strcat(pBueffel,pRead);
}
}
if(strstr(pBueffel,"TRANSACTIONFINISHED") == NULL)
if(strstr(pBueffel,"TRANSACTIONFINISHED") != NULL)
{
test = 1;
break;
@@ -209,6 +234,7 @@ int Synchronize(SConnection *pCon, SicsInterp *pSics, void *pData,
}
SicsWait(1);
}
pServ->simMode = 1;
if(!test)
{
SCWrite(pCon,"WARNING: sync server may not have exectued backup",
@@ -227,7 +253,15 @@ int Synchronize(SConnection *pCon, SicsInterp *pSics, void *pData,
return 0;
}
test = InterpExecute(pSics,internalCon,"restore");
if(syncFile != NULL)
{
sprintf(pBueffel,"restore %s",syncFile);
}
else
{
strcpy(pBueffel,"restore");
}
test = InterpExecute(pSics,internalCon,pBueffel);
SCDeleteConnection(internalCon);
ClearFixedStatus(eEager);
if(test != 1)