- More debugging of scriptcontext, mostly working now
- Created driveable SICSobj for standalone and as an adapter
This commit is contained in:
23
ascon.c
23
ascon.c
@ -117,10 +117,16 @@ static void AsconConnect(Ascon *a) {
|
||||
fcntl(a->fd, F_SETFL, oldopts | O_NONBLOCK);
|
||||
ret = connect(a->fd, (struct sockaddr *)&adr, sizeof(struct sockaddr_in));
|
||||
if (ret < 0) {
|
||||
if (errno != EINPROGRESS) {
|
||||
AsconError(a, "connect failed:", errno);
|
||||
return;
|
||||
}
|
||||
switch(errno) {
|
||||
case EINPROGRESS:
|
||||
case EALREADY:
|
||||
case EISCONN:
|
||||
a->state = AsconConnecting;
|
||||
break;
|
||||
default:
|
||||
AsconError(a, "connect failed:", errno);
|
||||
return;
|
||||
}
|
||||
}
|
||||
a->state = AsconConnecting;
|
||||
return;
|
||||
@ -289,6 +295,9 @@ int AsconStdHandler(Ascon *a) {
|
||||
DynStringConcat(a->wrBuffer, a->sendTerminator);
|
||||
a->wrPos = 0;
|
||||
a->state = AsconWriting;
|
||||
if(strstr(GetCharArray(a->wrBuffer),"@@NOSEND@@") != NULL){
|
||||
a->state = AsconWriteDone;
|
||||
}
|
||||
break;
|
||||
case AsconWriting:
|
||||
AsconReadGarbage(a->fd);
|
||||
@ -296,6 +305,10 @@ int AsconStdHandler(Ascon *a) {
|
||||
ret = AsconWriteChars(a->fd, GetCharArray(a->wrBuffer) + a->wrPos, l);
|
||||
if (ret < 0) {
|
||||
AsconError(a, "send failed:", errno);
|
||||
/*
|
||||
* Ooops: which state shall we go to after a write fail?
|
||||
* This seems to retry.
|
||||
*/
|
||||
} else {
|
||||
a->wrPos += ret;
|
||||
if (a->wrPos >= GetDynStringLength(a->wrBuffer)) {
|
||||
@ -476,6 +489,8 @@ AsconStatus AsconTask(Ascon *a) {
|
||||
now = DoubleTime();
|
||||
if (now > a->lastReconnect + a->reconnectInterval) {
|
||||
a->lastReconnect = now;
|
||||
close(a->fd);
|
||||
a->fd = -1;
|
||||
a->state = AsconConnectStart;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user