Another try ad getting write to work
This commit is contained in:
9
conman.c
9
conman.c
@ -229,6 +229,7 @@ static SConnection *CreateConnection(SicsInterp * pSics)
|
||||
pRes->conStart = time(NULL);
|
||||
pRes->write = SCNormalWrite;
|
||||
pRes->runLevel = RUNDRIVE;
|
||||
pRes->remote = 0;
|
||||
|
||||
/* initialise context variables */
|
||||
pRes->iCmdCtr = 0;
|
||||
@ -461,6 +462,7 @@ SConnection *SCCopyConnection(SConnection * pCon)
|
||||
result->iList = -1;
|
||||
result->runLevel = pCon->runLevel;
|
||||
result->data = pCon->data;
|
||||
result->remote = pCon->remote;
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1768,6 +1770,7 @@ int SCInvoke(SConnection * self, SicsInterp * pInter, char *pCommand)
|
||||
config File Filename Logs to another file
|
||||
config output normal | withcode | ACT Sets output mode
|
||||
config listen 0 | 1 enables commandlog listen mode
|
||||
config remote sets the remote connection flag
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
int ConfigCon(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
@ -1825,7 +1828,11 @@ int ConfigCon(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
} else if(strcmp(argv[1],"remote") == 0) {
|
||||
pMaster->remote = 1;
|
||||
pCon->remote = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* check no or args */
|
||||
if (argc < 3) {
|
||||
|
1
conman.h
1
conman.h
@ -71,6 +71,7 @@ typedef struct __SConnection {
|
||||
pCosta pStack; /* stack of pending commands */
|
||||
int contextStack; /* context stack: may go? */
|
||||
mkChannel *pSock; /* for temporary backwards compatability */
|
||||
int remote; /* true if this is a remote object connection */
|
||||
} SConnection;
|
||||
|
||||
#include "nserver.h"
|
||||
|
@ -241,6 +241,9 @@ static int DriveTaskFunc(void *data)
|
||||
} else {
|
||||
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);
|
||||
return 0;
|
||||
}
|
||||
@ -393,6 +396,9 @@ static int CountTaskFunc(void *data)
|
||||
ExeInterest(pServ->pExecutor,taskData->name, "finished with problem");
|
||||
}
|
||||
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;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
@ -240,8 +240,9 @@ static void ConnectRemoteObject(pRemoteOBJ self)
|
||||
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->writeInUse = 0;
|
||||
}
|
||||
@ -537,7 +538,7 @@ static void printSICS(char *answer, SConnection *pCon)
|
||||
while(pPtr != NULL){
|
||||
memset(line,0,sizeof(line));
|
||||
pPtr = stptok(pPtr,line,sizeof(line),"\n");
|
||||
if(strstr(line,"OK") == NULL){
|
||||
if(strstr(line,"OK") == NULL && strstr(line,"TASKFINISHED") == NULL){
|
||||
pCode = strstr(line,"@@");
|
||||
if(pCode != NULL){
|
||||
*pCode = '\0';
|
||||
@ -578,6 +579,7 @@ static int PrepareWriteHandle(pRemoteOBJ self, SConnection *pCon, int *newHandle
|
||||
*newHandle = 1;
|
||||
|
||||
transactCommand(handle,"protocol set withcode\r\n", command,sizeof(command));
|
||||
transactCommand(handle,"config remote\r\n",command,sizeof(command)-1);
|
||||
|
||||
} else {
|
||||
self->writeInUse = 1;
|
||||
@ -609,7 +611,7 @@ static void ProcessWriteResponse(pRemoteOBJ self, int handle, SConnection *pCon)
|
||||
printSICS(answer,pCon);
|
||||
}
|
||||
traceIO("RO","%s:%d: Received %s", self->host, self->port,answer);
|
||||
ANETreadConsume(handle,length);
|
||||
ANETreadConsume(handle,pEnd+strlen("TRANSACTIONFINISHED") - answer);
|
||||
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){
|
||||
ANETclose(handle);
|
||||
|
Reference in New Issue
Block a user