From b5d8f5d96aeff3e95cac135f9250da6e9d799382 Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Tue, 24 Jun 2008 15:12:22 +0200 Subject: added support for EGAIN while trying to receive data on gTLS session This maps to bugzilla bug 83: http://bugzilla.adiscon.com/show_bug.cgi?id=83 This is the first test version, posted to user for repro of the problem. It contains code to handle the case, HOWEVER, I have not been able to test it in a scenario where a retry actually happens while receiving (I dont't get this in my environment). So I assume it is buggy and will probably not work. --- tcpsrv.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'tcpsrv.c') diff --git a/tcpsrv.c b/tcpsrv.c index 94bcaaa7..b9f45723 100644 --- a/tcpsrv.c +++ b/tcpsrv.c @@ -406,7 +406,6 @@ Run(tcpsrv_t *pThis) int bIsReady; tcps_sess_t *pNewSess; nssel_t *pSel; - int state; ssize_t iRcvd; ISOBJ_TYPE_assert(pThis, tcpsrv); @@ -457,18 +456,15 @@ Run(tcpsrv_t *pThis) /* Receive message */ iRet = pThis->pRcvData(pThis->pSessions[iTCPSess], buf, sizeof(buf), &iRcvd); - if(iRet == RS_RET_CLOSED) { + switch(iRet) { + case RS_RET_CLOSED: pThis->pOnRegularClose(pThis->pSessions[iTCPSess]); tcps_sess.Destruct(&pThis->pSessions[iTCPSess]); - } else if(iRet == RS_RET_RETRY) { + break; + case RS_RET_RETRY: /* we simply ignore retry - this is not an error, but we also have not received anything */ - } else if(iRet == RS_RET_OK) { - errno = 0; - errmsg.LogError(NO_ERRCODE, "netstream session %p will be closed due to error\n", - pThis->pSessions[iTCPSess]->pStrm); - pThis->pOnErrClose(pThis->pSessions[iTCPSess]); - tcps_sess.Destruct(&pThis->pSessions[iTCPSess]); - } else { + break; + case RS_RET_OK: /* valid data received, process it! */ if(tcps_sess.DataRcvd(pThis->pSessions[iTCPSess], buf, iRcvd) != RS_RET_OK) { /* in this case, something went awfully wrong. @@ -479,6 +475,14 @@ Run(tcpsrv_t *pThis) pThis->pOnErrClose(pThis->pSessions[iTCPSess]); tcps_sess.Destruct(&pThis->pSessions[iTCPSess]); } + break; + default: + errno = 0; + errmsg.LogError(NO_ERRCODE, "netstream session %p will be closed due to error\n", + pThis->pSessions[iTCPSess]->pStrm); + pThis->pOnErrClose(pThis->pSessions[iTCPSess]); + tcps_sess.Destruct(&pThis->pSessions[iTCPSess]); + break; } --nfds; /* indicate we have processed one */ } -- cgit