Another try ad getting write to work

This commit is contained in:
2015-03-19 16:12:35 +01:00
parent 0097a2f3cb
commit 0d0c90cee7
4 changed files with 38 additions and 5 deletions

View File

@ -229,6 +229,7 @@ static SConnection *CreateConnection(SicsInterp * pSics)
pRes->conStart = time(NULL); pRes->conStart = time(NULL);
pRes->write = SCNormalWrite; pRes->write = SCNormalWrite;
pRes->runLevel = RUNDRIVE; pRes->runLevel = RUNDRIVE;
pRes->remote = 0;
/* initialise context variables */ /* initialise context variables */
pRes->iCmdCtr = 0; pRes->iCmdCtr = 0;
@ -461,6 +462,7 @@ SConnection *SCCopyConnection(SConnection * pCon)
result->iList = -1; result->iList = -1;
result->runLevel = pCon->runLevel; result->runLevel = pCon->runLevel;
result->data = pCon->data; result->data = pCon->data;
result->remote = pCon->remote;
return result; return result;
} }
@ -1768,6 +1770,7 @@ int SCInvoke(SConnection * self, SicsInterp * pInter, char *pCommand)
config File Filename Logs to another file config File Filename Logs to another file
config output normal | withcode | ACT Sets output mode config output normal | withcode | ACT Sets output mode
config listen 0 | 1 enables commandlog listen mode config listen 0 | 1 enables commandlog listen mode
config remote sets the remote connection flag
---------------------------------------------------------------------------*/ ---------------------------------------------------------------------------*/
int ConfigCon(SConnection * pCon, SicsInterp * pSics, void *pData, int ConfigCon(SConnection * pCon, SicsInterp * pSics, void *pData,
@ -1825,7 +1828,11 @@ int ConfigCon(SConnection * pCon, SicsInterp * pSics, void *pData,
SCSendOK(pCon); SCSendOK(pCon);
return 1; return 1;
} }
} } else if(strcmp(argv[1],"remote") == 0) {
pMaster->remote = 1;
pCon->remote = 1;
return 1;
}
/* check no or args */ /* check no or args */
if (argc < 3) { if (argc < 3) {

View File

@ -71,6 +71,7 @@ typedef struct __SConnection {
pCosta pStack; /* stack of pending commands */ pCosta pStack; /* stack of pending commands */
int contextStack; /* context stack: may go? */ int contextStack; /* context stack: may go? */
mkChannel *pSock; /* for temporary backwards compatability */ mkChannel *pSock; /* for temporary backwards compatability */
int remote; /* true if this is a remote object connection */
} SConnection; } SConnection;
#include "nserver.h" #include "nserver.h"

View File

@ -241,6 +241,9 @@ static int DriveTaskFunc(void *data)
} else { } else {
ExeInterest(pServ->pExecutor,taskData->name, "finished with problem"); ExeInterest(pServ->pExecutor,taskData->name, "finished with problem");
} }
if(taskData->pCon->remote){
SCPrintf(taskData->pCon,eValue,"TASKFINISHED:%s", taskData->name);
}
traceSys("drive","DriveTask %s finished with state %d", taskData->name,status); traceSys("drive","DriveTask %s finished with state %d", taskData->name,status);
return 0; return 0;
} }
@ -393,6 +396,9 @@ static int CountTaskFunc(void *data)
ExeInterest(pServ->pExecutor,taskData->name, "finished with problem"); ExeInterest(pServ->pExecutor,taskData->name, "finished with problem");
} }
traceSys("count","CountTask %s finished with state %d", taskData->name,status); traceSys("count","CountTask %s finished with state %d", taskData->name,status);
if(taskData->pCon->remote){
SCPrintf(taskData->pCon,eValue,"TASKFINISHED:%s", taskData->name);
}
return 0; return 0;
} }
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/

View File

@ -240,8 +240,9 @@ static void ConnectRemoteObject(pRemoteOBJ self)
status = LLDnodePtr2Next(self->readList); status = LLDnodePtr2Next(self->readList);
} }
transactCommand(self->writeHandle,"protocol set withcode\r\n", command,sizeof(command)); transactCommand(self->writeHandle,"protocol set withcode\r\n", command,sizeof(command)-1);
transactCommand(self->writeHandle,"config remote\r\n",command,sizeof(command)-1);
self->connected = 1; self->connected = 1;
self->writeInUse = 0; self->writeInUse = 0;
} }
@ -537,7 +538,7 @@ static void printSICS(char *answer, SConnection *pCon)
while(pPtr != NULL){ while(pPtr != NULL){
memset(line,0,sizeof(line)); memset(line,0,sizeof(line));
pPtr = stptok(pPtr,line,sizeof(line),"\n"); pPtr = stptok(pPtr,line,sizeof(line),"\n");
if(strstr(line,"OK") == NULL){ if(strstr(line,"OK") == NULL && strstr(line,"TASKFINISHED") == NULL){
pCode = strstr(line,"@@"); pCode = strstr(line,"@@");
if(pCode != NULL){ if(pCode != NULL){
*pCode = '\0'; *pCode = '\0';
@ -578,6 +579,7 @@ static int PrepareWriteHandle(pRemoteOBJ self, SConnection *pCon, int *newHandle
*newHandle = 1; *newHandle = 1;
transactCommand(handle,"protocol set withcode\r\n", command,sizeof(command)); transactCommand(handle,"protocol set withcode\r\n", command,sizeof(command));
transactCommand(handle,"config remote\r\n",command,sizeof(command)-1);
} else { } else {
self->writeInUse = 1; self->writeInUse = 1;
@ -609,7 +611,7 @@ static void ProcessWriteResponse(pRemoteOBJ self, int handle, SConnection *pCon)
printSICS(answer,pCon); printSICS(answer,pCon);
} }
traceIO("RO","%s:%d: Received %s", self->host, self->port,answer); traceIO("RO","%s:%d: Received %s", self->host, self->port,answer);
ANETreadConsume(handle,length); ANETreadConsume(handle,pEnd+strlen("TRANSACTIONFINISHED") - answer);
break; break;
} }
} }
@ -688,6 +690,23 @@ static hdbCallbackReturn ROWriteCallback(pHdb currentNode, void *userData,
} }
} }
/*
Do I have to wait for a TASKFINISHED?
*/
command = GetHdbProp(currentNode,"taskwait");
if(command != NULL){
while(1) {
TaskYield(pServ->pTasker);
answer = ANETreadPtr(handle,&length);
if(length > 0 && strstr(answer,"TASKFINISHED") != NULL){
printSICS(answer,pCon);
traceIO("RO","%s:%d:Received %s", self->host,self->port,answer);
ANETreadConsume(handle,length);
break;
}
}
}
if(newHandle){ if(newHandle){
ANETclose(handle); ANETclose(handle);