diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2008-06-24 15:12:22 +0200 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2008-06-24 15:12:22 +0200 |
commit | b5d8f5d96aeff3e95cac135f9250da6e9d799382 (patch) | |
tree | 36c2a72530fa881120cf2cd315784461d6a8d25c /runtime/nsdsel_gtls.c | |
parent | b711a34a075cf3979f48937f8af8b05030644e82 (diff) | |
download | rsyslog-b5d8f5d96aeff3e95cac135f9250da6e9d799382.tar.gz rsyslog-b5d8f5d96aeff3e95cac135f9250da6e9d799382.tar.xz rsyslog-b5d8f5d96aeff3e95cac135f9250da6e9d799382.zip |
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.
Diffstat (limited to 'runtime/nsdsel_gtls.c')
-rw-r--r-- | runtime/nsdsel_gtls.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/runtime/nsdsel_gtls.c b/runtime/nsdsel_gtls.c index 7b359950..368c4df3 100644 --- a/runtime/nsdsel_gtls.c +++ b/runtime/nsdsel_gtls.c @@ -74,6 +74,10 @@ Add(nsdsel_t *pNsdsel, nsd_t *pNsd, nsdsel_waitOp_t waitOp) ISOBJ_TYPE_assert(pThis, nsdsel_gtls); ISOBJ_TYPE_assert(pNsdGTLS, nsd_gtls); if(pNsdGTLS->iMode == 1) { + if(waitOp == NSDSEL_RD && gtlsHasRcvInBuffer(pNsdGTLS)) { + ++pThis->iBufferRcvReady; + FINALIZE; + } if(pNsdGTLS->rtryCall != gtlsRtry_None) { if(gnutls_record_get_direction(pNsdGTLS->sess) == 0) { CHKiRet(nsdsel_ptcp.Add(pThis->pTcp, pNsdGTLS->pTcp, NSDSEL_RD)); @@ -87,6 +91,7 @@ Add(nsdsel_t *pNsdsel, nsd_t *pNsd, nsdsel_waitOp_t waitOp) /* if we reach this point, we need no special handling */ CHKiRet(nsdsel_ptcp.Add(pThis->pTcp, pNsdGTLS->pTcp, waitOp)); +RUNLOG_VAR("%d", pThis->iBufferRcvReady); finalize_it: RETiRet; } @@ -102,7 +107,14 @@ Select(nsdsel_t *pNsdsel, int *piNumReady) nsdsel_gtls_t *pThis = (nsdsel_gtls_t*) pNsdsel; ISOBJ_TYPE_assert(pThis, nsdsel_gtls); - iRet = nsdsel_ptcp.Select(pThis->pTcp, piNumReady); +RUNLOG_VAR("%d", pThis->iBufferRcvReady); + if(pThis->iBufferRcvReady > 0) { + /* we still have data ready! */ + *piNumReady = pThis->iBufferRcvReady; + } else { + iRet = nsdsel_ptcp.Select(pThis->pTcp, piNumReady); + } + RETiRet; } @@ -134,6 +146,10 @@ doRetry(nsd_gtls_t *pNsd) CHKiRet(gtlsChkPeerAuth(pNsd)); } break; + case gtlsRtry_recv: + dbgprintf("retrying gtls recv, nsd: %p\n", pNsd); + CHKiRet(gtlsRecordRecv(pNsd)); + break; default: assert(0); /* this shall not happen! */ dbgprintf("ERROR: pNsd->rtryCall invalid in nsdsel_gtls.c:%d\n", __LINE__); @@ -172,6 +188,10 @@ IsReady(nsdsel_t *pNsdsel, nsd_t *pNsd, nsdsel_waitOp_t waitOp, int *pbIsReady) ISOBJ_TYPE_assert(pThis, nsdsel_gtls); ISOBJ_TYPE_assert(pNsdGTLS, nsd_gtls); if(pNsdGTLS->iMode == 1) { + if(waitOp == NSDSEL_RD && gtlsHasRcvInBuffer(pNsdGTLS)) { + *pbIsReady = 1; + FINALIZE; + } if(pNsdGTLS->rtryCall != gtlsRtry_None) { CHKiRet(doRetry(pNsdGTLS)); /* we used this up for our own internal processing, so the socket |