summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-02-27 07:15:10 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-02-27 07:15:10 +0200
commit66b1193cfd3070bc1746ddce691e1784f0f04395 (patch)
treecb23908cbc9065bb610ac486624d2ec385fda87e
parent3b839cf81cac1fff8870de22432ea9c294385351 (diff)
GmRequest: Handling early termination
IssueID #181
-rw-r--r--src/gmrequest.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/gmrequest.c b/src/gmrequest.c
index f4d770ab..0208dc94 100644
--- a/src/gmrequest.c
+++ b/src/gmrequest.c
@@ -227,7 +227,12 @@ static int processIncomingData_GmRequest_(iGmRequest *d, const iBlock *data) {
227static void readIncoming_GmRequest_(iGmRequest *d, iTlsRequest *req) { 227static void readIncoming_GmRequest_(iGmRequest *d, iTlsRequest *req) {
228 lock_Mutex(d->mtx); 228 lock_Mutex(d->mtx);
229 iGmResponse *resp = d->resp; 229 iGmResponse *resp = d->resp;
230 iAssert(d->state != finished_GmRequestState); /* notifications out of order? */ 230 if (d->state == finished_GmRequestState || d->state == failure_GmRequestState) {
231 /* The request has already finished or been aborted (e.g., invalid header). */
232 delete_Block(readAll_TlsRequest(req));
233 unlock_Mutex(d->mtx);
234 return;
235 }
231 iBlock * data = readAll_TlsRequest(req); 236 iBlock * data = readAll_TlsRequest(req);
232 const int ubits = processIncomingData_GmRequest_(d, data); 237 const int ubits = processIncomingData_GmRequest_(d, data);
233 iBool notifyUpdate = (ubits & 1) != 0; 238 iBool notifyUpdate = (ubits & 1) != 0;
@@ -552,7 +557,7 @@ void submit_GmRequest(iGmRequest *d) {
552 remove_Block(&path->chars, 0, 1); 557 remove_Block(&path->chars, 0, 1);
553 } 558 }
554#endif 559#endif
555 iFile * f = new_File(path); 560 iFile *f = new_File(path);
556 if (open_File(f, readOnly_FileMode)) { 561 if (open_File(f, readOnly_FileMode)) {
557 /* TODO: Check supported file types: images, audio */ 562 /* TODO: Check supported file types: images, audio */
558 /* TODO: Detect text files based on contents? E.g., is the content valid UTF-8. */ 563 /* TODO: Detect text files based on contents? E.g., is the content valid UTF-8. */