| 374 | |
| 375 | |
| 376 | bool cURLManager::perform() { |
| 377 | if (multiHandle == NULL) { |
| 378 | return false; |
| 379 | } |
| 380 | |
| 381 | if (!inited) { |
| 382 | setup(); |
| 383 | } |
| 384 | |
| 385 | int activeTransfers = 0; |
| 386 | CURLMcode result; |
| 387 | justCalled = false; |
| 388 | while (true) { |
| 389 | result = curl_multi_perform(multiHandle, &activeTransfers); |
| 390 | if (result != CURLM_CALL_MULTI_PERFORM) { |
| 391 | break; |
| 392 | } |
| 393 | } |
| 394 | if (result != CURLM_OK) |
| 395 | debugf(1, "Error while doing multi_perform from libcurl %d : %s\n", |
| 396 | result, errorBuffer); |
| 397 | |
| 398 | int msgs_in_queue; |
| 399 | CURLMsg* pendingMsg; |
| 400 | CURL* easy; |
| 401 | |
| 402 | std::vector<cURLManager*> toBeDeleted; |
| 403 | |
| 404 | while (true) { |
| 405 | pendingMsg = curl_multi_info_read(multiHandle, &msgs_in_queue); |
| 406 | if (!pendingMsg) { |
| 407 | break; |
| 408 | } |
| 409 | |
| 410 | easy = pendingMsg->easy_handle; |
| 411 | |
| 412 | if (cURLMap.count(easy)) { |
| 413 | cURLMap[easy]->infoComplete(pendingMsg->data.result); |
| 414 | if (cURLMap[easy]->deleteOnDone) { |
| 415 | toBeDeleted.push_back(cURLMap[easy]); |
| 416 | } |
| 417 | } |
| 418 | |
| 419 | if (msgs_in_queue <= 0) { |
| 420 | break; |
| 421 | } |
| 422 | } |
| 423 | |
| 424 | for (size_t i = 0; i < toBeDeleted.size(); i++) { |
| 425 | delete toBeDeleted[i]; |
| 426 | } |
| 427 | toBeDeleted.clear(); |
| 428 | |
| 429 | return justCalled; |
| 430 | } |
| 431 | |
| 432 | |
| 433 | void cURLManager::infoComplete(CURLcode result) { |
nothing calls this directly
no test coverage detected