138 {
139
141
142 self->locals.
handle = curl_multi_init();
143 assert(self->locals.
handle);
144
145 while (true) {
146 int ret;
147
150
152 break;
153 }
154
156 continue;
157 }
158
160
163
164 if (task->locals.
handle) {
165 const CURLcode err = curl_easy_pause(task->locals.
handle, CURLPAUSE_ALL);
166 assert(err == CURLE_OK);
167 }
168
170
172
173 if (task->locals.
handle == NULL) {
174
176 assert(task->locals.
handle);
177
178 const CURLMcode merr = curl_multi_add_handle(self->locals.
handle, task->locals.
handle);
179 assert(merr == CURLM_OK);
180 } else {
181 const CURLcode err = curl_easy_pause(task->locals.
handle, CURLPAUSE_CONT);
182 assert(err == CURLE_OK);
183 }
184
186
188
189 if (task->locals.
handle) {
190 const CURLMcode merr = curl_multi_remove_handle(self->locals.
handle, task->locals.
handle);
191 assert(merr == CURLM_OK);
192 }
193
195
198 }
199
201
202 synchronized(self->locals.
lock, {
204 });
206
207 synchronized(self->locals.
lock, {
209 });
210 }
211 }
212
213 CURLMcode merr = curl_multi_wait(self->locals.
handle, NULL, 0, 0, NULL);
214 assert(merr == CURLM_OK);
215
216 merr = curl_multi_perform(self->locals.
handle, &ret);
217 assert(merr == CURLM_OK);
218
219 CURLMsg *message;
220 while ((message = curl_multi_info_read(self->locals.
handle, &ret))) {
221
224
226 if (t->locals.
handle == message->easy_handle) {
227 task = t;
228 break;
229 }
230 }
231
232 assert(task);
233
234 if (message->msg == CURLMSG_DONE) {
235
236 merr = curl_multi_remove_handle(self->locals.
handle, task->locals.
handle);
237 assert(merr == CURLM_OK);
238
240
242
244 task->
completion(task, message->data.result == CURLE_OK);
245 }
246
248
249 synchronized(self->locals.
lock, {
251 });
252 }
253 }
254
256 }
257
258 curl_multi_cleanup(self->locals.
handle);
259
260 return NULL;
261}
@ URLSESSIONTASK_RESUMING
@ URLSESSIONTASK_CANCELED
@ URLSESSIONTASK_SUSPENDING
@ URLSESSIONTASK_SUSPENDED
@ URLSESSIONTASK_COMPLETED
@ URLSESSIONTASK_CANCELING
void wait(Condition *self)
Waits indefinitely for this Condition to be signaled.
void removeObject(MutableArray *self, const ident obj)
Removes the specified Object from this MutableArray.
int httpStatusCode
The HTTP response status code.
ident handle
The libcurl handle.
struct URLResponse * response
The response.
ident handle
The backing libcurl handle.
void setup(URLSessionTask *)
Sets up this task.
void teardown(URLSessionTask *)
Tears down this task.
URLSessionTaskState state
The state.
URLSessionTaskCompletion completion
The completion function.