Revert "Run ghttp_process in async mode, call TaskYield and add an abort action"

This reverts commit 2cf74d16c504549247305ad4cfcba5e5704157ab.
This commit is contained in:
Douglas Clowes
2013-08-21 15:53:26 +10:00
parent f5dd71f4fb
commit 9e343223ea

View File

@@ -79,48 +79,12 @@ typedef struct {
pICallBack pCall;
}anstoHttp, *pAnstoHttp;
/*------------------------------------------------------------------*/
static ghttp_status anstoLocalProcess(pAnstoHttp self) {
ghttp_status httpStatus;
pTaskMan pTasker = GetTasker();
if(self->asyncRunning) {
httpStatus = ghttp_process(self->syncRequest);
/*
* Service other SICS tasks while we wait,
* but do not run the taskloop during initialisation
*/
if (pTasker == NULL)
pTasker = GetTasker();
if (pTasker && (pServ->dummyCon != NULL))
TaskYield(pTasker);
return httpStatus;
} else {
ghttp_set_sync(self->syncRequest, ghttp_async);
do {
httpStatus = ghttp_process(self->syncRequest);
if (httpStatus != ghttp_not_done)
break;
/*
* Service other SICS tasks while we wait,
* but do not run the taskloop during initialisation
*/
if (pTasker == NULL)
pTasker = GetTasker();
if (pTasker && (pServ->dummyCon != NULL))
TaskYield(pTasker);
} while(1);
ghttp_set_sync(self->syncRequest, ghttp_sync);
return httpStatus;
}
}
/*------------------------------------------------------------------*/
static int anstoHttpGetPrepare(pAnstoHttp self, char *request){
char url[512];
ghttp_status httpStatus;
if(self->asyncRunning){
while((httpStatus = anstoLocalProcess(self))
while((httpStatus = ghttp_process(self->syncRequest))
== ghttp_not_done){
}
self->asyncRunning = 0;
@@ -183,13 +147,13 @@ static int anstoHttpGet(pAnstoHttp self, char *request){
* try two times: a reconnect is no error
*/
ghttp_prepare(self->syncRequest);
httpStatus = anstoLocalProcess(self);
httpStatus = ghttp_process(self->syncRequest);
if(httpStatus != ghttp_done){
ghttp_close(self->syncRequest);
if (!anstoHttpGetPrepare(self,request))
return 0; // MJL return here if failed
ghttp_prepare(self->syncRequest); // MJL be sure to call ghttp_prepare before each ghttp_process
httpStatus = anstoLocalProcess(self);
httpStatus = ghttp_process(self->syncRequest);
}
if(httpStatus != ghttp_done){
strncpy(self->hmError,"Reconnect", 511);
@@ -290,7 +254,7 @@ static int AnstoHttpConfigure(pHistDriver self, SConnection *pCon,
pPriv->passWord);
ghttp_set_sync(pPriv->syncRequest,ghttp_sync);
status = ghttp_prepare(pPriv->syncRequest);
httpStatus = anstoLocalProcess(pPriv);
httpStatus = ghttp_process(pPriv->syncRequest);
confData = (char *)ghttp_get_body(pPriv->syncRequest);
if(httpStatus != ghttp_done){
/* we may need to reconnect.....
@@ -445,14 +409,14 @@ static int AnstoHttpStatus_Base(pHistDriver self,SConnection *pCon,int *pextrast
}
pPriv->asyncRunning = 1;
}
httpStatus = anstoLocalProcess(pPriv);
httpStatus = ghttp_process(pPriv->syncRequest);
switch(httpStatus){
case ghttp_error:
ghttp_close(pPriv->syncRequest);
pPriv->asyncRunning = 0; // MJL bug fix 9/03/07 moved by DFC
anstoHttpGetPrepare(pPriv,statusdaq);
ghttp_prepare(pPriv->syncRequest);
httpStatus = anstoLocalProcess(pPriv);
httpStatus = ghttp_process(pPriv->syncRequest);
if(httpStatus != ghttp_done){
strncpy(pPriv->hmError,"Reconnect", 511);
pPriv->errorCode = SERVERERROR;
@@ -1027,16 +991,6 @@ pHistDriver CreateAnstoHttpDriver(pStringDict pOption){
SCSendOK(pCon);
return 1;
}
if(strcmp(argv[1],"abort") == 0) {
pAnstoHttp pPriv = NULL;
if(!SCMatchRights(pCon,usUser)) {
return 0;
}
pPriv = (pAnstoHttp)self->pDriv->pPriv;
ghttp_close(pPriv->syncRequest);
SCSendOK(pCon);
return 1;
}
return HistAction(pCon, pSics, pData, argc, argv);
}