From 6b2dd9ce58d3743dd7d044bb769cd78dbec73c3a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaakko=20Ker=C3=A4nen?= jaakko.keranen@iki.fi
Date: Tue, 17 Aug 2021 10:46:50 +0300
Subject: [PATCH 1/1] TlsRequest: Threading issue when waiting for data
It was possible to get stuck waiting for incoming data when some
had already arrived after the last check.
src/tlsrequest.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/tlsrequest.c b/src/tlsrequest.c
index af54236..d746792 100644
--- a/src/tlsrequest.c
+++ b/src/tlsrequest.c
@@ -65,7 +65,7 @@ static iTlsRequest *currentRequestForThread_Context_(iContext *d) {
}
static void setCurrentRequestForThread_Context_(iContext *d, iTlsRequest *request) {
}
static int verifyCallback_Context_(int preverifyOk, X509_STORE_CTX *storeCtx) {
@@ -97,7 +97,7 @@ static int verifyCallback_Context_(int preverifyOk, X509_STORE_CTX *storeCtx) {
if (!result) {
certificateVerifyFailed_TlsRequest_(request, cert);
}
delete_TlsCertificate(cert); /* free the reference */
return result;
}
@@ -854,13 +854,15 @@ static iThreadResult run_TlsRequest_(iThread *thread) {
lock_Mutex(&d->mtx);
if (d->status == submitted_TlsRequestStatus) {
unlock_Mutex(&d->mtx);
/* Wait for incoming data. */
/* Wait for incoming data if there isn't some available. */
lock_Mutex(&d->incomingMtx);
wait_Condition(&d->gotIncoming, &d->incomingMtx);
if (isEmpty_Block(d->incoming)) {
wait_Condition(&d->gotIncoming, &d->incomingMtx);
}
unlock_Mutex(&d->incomingMtx);
}
else {
-// fprintf(stderr, "[TlsRequest] run loop exiting, status %d\n", d->status);
//fprintf(stderr, "[TlsRequest] run loop exiting, status %d\n", d->status);
unlock_Mutex(&d->mtx);
break;
}
--
2.25.1
text/plain
This content has been proxied by September (ba2dc).