Bug 198993

Summary: [Curl] CurlRequestScheduler doesn't terminate worker thread in a certain situation.
Product: WebKit Reporter: Takashi Komori <takashi.komori>
Component: PlatformAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: basuke, commit-queue, don.olmstead, Hironori.Fujii, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch none

Takashi Komori
Reported 2019-06-19 00:31:09 PDT
When a CurlRequest receives didReceiveDataCallback from libcurl, it append a task for main thread by calling callClient. If CurlRequest::invalidateClient is called before the task is processed, the task will not be processed properly. This is because invalidateClient changes m_client to nullptr and the task appended by CurlRequest::callClient checks if m_client is null. When calling CurlRequest::didReceiveData task is not processed properly, a paused connection could remain. In this case CurlRequestScheduler never releases the client related to it. Eventually this causes that CurlRequestScheduler's worker thread keeps working. This CurlRequest::invalidateClient() is called from the destructor of NetworkDataTaskCurl. To avoid this situation, we should cancel the request before invalidate.
Attachments
Patch (1.53 KB, patch)
2019-06-19 00:56 PDT, Takashi Komori
no flags
Takashi Komori
Comment 1 2019-06-19 00:56:31 PDT
Fujii Hironori
Comment 2 2019-06-19 03:38:08 PDT
(In reply to Takashi Komori from comment #0) > When calling CurlRequest::didReceiveData task is not processed properly, a > paused connection could remain. Why can it remain? > In this case CurlRequestScheduler never releases the client related to it. Really? It seems that CurlRequestScheduler calls completeTransfer.
WebKit Commit Bot
Comment 3 2019-06-19 08:11:36 PDT
Comment on attachment 372442 [details] Patch Clearing flags on attachment: 372442 Committed r246588: <https://trac.webkit.org/changeset/246588>
WebKit Commit Bot
Comment 4 2019-06-19 08:11:38 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 5 2019-06-19 08:12:18 PDT
Takashi Komori
Comment 6 2019-06-19 20:54:18 PDT
(In reply to Fujii Hironori from comment #2) > (In reply to Takashi Komori from comment #0) > > When calling CurlRequest::didReceiveData task is not processed properly, a > > paused connection could remain. > > Why can it remain? > > > In this case CurlRequestScheduler never releases the client related to it. > > Really? It seems that CurlRequestScheduler calls completeTransfer. To be precise, the task added by didreceiveData is not processed properly. And when that task is not processed, the connection rmains paused. CurlRequest::didReceiveData (PAUSE) CurlRequest::invokeDidReceiveResponse | | (Add task by using callClient) | NetworkDataTaskCurl::curlDidReceiveResponse NetworkDataTaskCurl::invokeDidReceiveResponse CurlRequest::completeDidReceiveResponse (UNPAUSE) CrrlRequest::didCompleteTransfer In this case, paused connection won't return CURLMSG_DONE message and CurlRequestScheduler::completeTransfer will not be invoked.
Fujii Hironori
Comment 7 2019-06-19 21:16:42 PDT
I got the idea. Thanks.
Note You need to log in before you can comment on or make changes to this bug.