- Major changes folling the rework of the connection object

- Added support for galil controllers
This commit is contained in:
koennecke
2009-02-03 08:07:30 +00:00
parent 9374bea841
commit 6c7bb14fad
29 changed files with 364 additions and 139 deletions

View File

@ -8,6 +8,7 @@
*
* Mark Koennecke, June 2008
*/
#include <stdio.h>
#include <ascon.h>
#include <ascon.i>
#include <ghttp.h>
@ -97,6 +98,8 @@ static int HttpHandler(Ascon *a) {
int socke, selStat;
fd_set rmask;
struct timeval tmo = {0,0};
char buffer[1024];
ghttp_current_status procStatus;
switch (a->state) {
case AsconConnectStart:
@ -109,6 +112,7 @@ static int HttpHandler(Ascon *a) {
if(configRequest(a)){
a->state = AsconWriting;
}
return 1;
break;
case AsconWriting:
status = ghttp_process(pHttp->request);
@ -122,7 +126,10 @@ static int HttpHandler(Ascon *a) {
DynStringConcat(a->rdBuffer,"Server error");
a->state = AsconReadDone;
} else {
a->state = AsconWriteDone;
procStatus = ghttp_get_status(pHttp->request);
if(procStatus.proc == ghttp_proc_response_hdrs || procStatus.proc == ghttp_proc_response){
a->state = AsconWriteDone;
}
}
a->start = DoubleTime();
DynStringClear(a->rdBuffer);
@ -131,21 +138,28 @@ static int HttpHandler(Ascon *a) {
socke = ghttp_get_socket(pHttp->request);
FD_ZERO(&rmask);
FD_SET(socke,&rmask);
selStat = uselect(socke+1,&rmask, NULL, NULL, &tmo);
if(selStat != 0){
status = ghttp_process(pHttp->request);
a->state = AsconReading;
} else {
selStat = uselect(socke+1,&rmask, NULL, NULL, &tmo);
if(selStat > 0 && FD_ISSET(socke,&rmask)){
status = ghttp_process(pHttp->request);
a->state = AsconReading;
} else {
if(DoubleTime() > a->start + a->timeout){
AsconError(a," read timeout", 0);
a->state = AsconTimeout;
/* this to clear the line */
ghttp_close(pHttp->request);
}
}
return 1;
}
return 1;
break;
case AsconReading:
socke = ghttp_get_socket(pHttp->request);
FD_ZERO(&rmask);
FD_SET(socke,&rmask);
selStat = select(socke+1,&rmask, NULL, NULL, &tmo);
if(selStat == 0 ){
return 1;
}
status = ghttp_process(pHttp->request);
switch(status){
case ghttp_not_done: