diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-08-08 14:57:17 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-08-08 14:57:17 +0300 |
commit | fa75afdf7d9b9036dcaa373e01250cb68176488b (patch) | |
tree | e3f9d683b1425bdb198fcba2bde21abb59234e3b | |
parent | 66d425de8597cd9f88a2657505b7098d02cc9617 (diff) |
Cancel GmRequest from the main thread
Doing it in the SDL timer thread causes mutex lockups.
-rw-r--r-- | src/gmrequest.c | 8 | ||||
-rw-r--r-- | src/gmrequest.h | 1 | ||||
-rw-r--r-- | src/ui/documentwidget.c | 5 |
3 files changed, 12 insertions, 2 deletions
diff --git a/src/gmrequest.c b/src/gmrequest.c index 9591885a..7cc8b897 100644 --- a/src/gmrequest.c +++ b/src/gmrequest.c | |||
@@ -120,12 +120,16 @@ void setUrl_GmRequest(iGmRequest *d, const iString *url) { | |||
120 | } | 120 | } |
121 | 121 | ||
122 | static uint32_t timedOutWhileReceivingBody_GmRequest_(uint32_t interval, void *obj) { | 122 | static uint32_t timedOutWhileReceivingBody_GmRequest_(uint32_t interval, void *obj) { |
123 | iGmRequest *d = obj; | 123 | /* Note: Called from SDL's timer thread. */ |
124 | cancel_TlsRequest(d->req); | 124 | postCommandf_App("gmrequest.timeout request:%p", obj); |
125 | iUnused(interval); | 125 | iUnused(interval); |
126 | return 0; | 126 | return 0; |
127 | } | 127 | } |
128 | 128 | ||
129 | void cancel_GmRequest(iGmRequest *d) { | ||
130 | cancel_TlsRequest(d->req); | ||
131 | } | ||
132 | |||
129 | static void restartTimeout_GmRequest_(iGmRequest *d) { | 133 | static void restartTimeout_GmRequest_(iGmRequest *d) { |
130 | /* Note: `d` is currently locked. */ | 134 | /* Note: `d` is currently locked. */ |
131 | if (d->timeoutId) { | 135 | if (d->timeoutId) { |
diff --git a/src/gmrequest.h b/src/gmrequest.h index c7d9d738..3b2ee3b3 100644 --- a/src/gmrequest.h +++ b/src/gmrequest.h | |||
@@ -39,6 +39,7 @@ iDeclareAudienceGetter(GmRequest, finished) | |||
39 | 39 | ||
40 | void setUrl_GmRequest (iGmRequest *, const iString *url); | 40 | void setUrl_GmRequest (iGmRequest *, const iString *url); |
41 | void submit_GmRequest (iGmRequest *); | 41 | void submit_GmRequest (iGmRequest *); |
42 | void cancel_GmRequest (iGmRequest *); | ||
42 | 43 | ||
43 | iBool isFinished_GmRequest (const iGmRequest *); | 44 | iBool isFinished_GmRequest (const iGmRequest *); |
44 | enum iGmStatusCode status_GmRequest (const iGmRequest *); | 45 | enum iGmStatusCode status_GmRequest (const iGmRequest *); |
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 9c8c93c6..8cc47e2a 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -792,6 +792,11 @@ static iBool handleCommand_DocumentWidget_(iDocumentWidget *d, const char *cmd) | |||
792 | postCommandf_App("document.changed url:%s", cstr_String(d->url)); | 792 | postCommandf_App("document.changed url:%s", cstr_String(d->url)); |
793 | return iFalse; | 793 | return iFalse; |
794 | } | 794 | } |
795 | else if (equal_Command(cmd, "gmrequest.timeout") && | ||
796 | pointerLabel_Command(cmd, "request") == d->request) { | ||
797 | cancel_GmRequest(d->request); | ||
798 | return iFalse; | ||
799 | } | ||
795 | else if (equal_Command(cmd, "document.request.cancelled") && document_Command(cmd) == d) { | 800 | else if (equal_Command(cmd, "document.request.cancelled") && document_Command(cmd) == d) { |
796 | postCommand_App("navigate.back"); | 801 | postCommand_App("navigate.back"); |
797 | return iFalse; | 802 | return iFalse; |