| 476 | } |
| 477 | |
| 478 | static apr_status_t md_curl_multi_perform(md_http_t *http, apr_pool_t *p, |
| 479 | md_http_next_req *nextreq, void *baton) |
| 480 | { |
| 481 | md_http_t *sub_http; |
| 482 | md_http_request_t *req; |
| 483 | CURLM *curlm = NULL; |
| 484 | CURLMcode mc; |
| 485 | struct CURLMsg *curlmsg; |
| 486 | apr_array_header_t *http_spares; |
| 487 | apr_array_header_t *requests; |
| 488 | int i, running, numfds, slowdown, msgcount; |
| 489 | apr_status_t rv; |
| 490 | |
| 491 | http_spares = apr_array_make(p, 10, sizeof(md_http_t*)); |
| 492 | requests = apr_array_make(p, 10, sizeof(md_http_request_t*)); |
| 493 | curlm = curl_multi_init(); |
| 494 | if (!curlm) { |
| 495 | rv = APR_ENOMEM; |
| 496 | goto leave; |
| 497 | } |
| 498 | |
| 499 | running = 1; |
| 500 | slowdown = 0; |
| 501 | while(1) { |
| 502 | while (1) { |
| 503 | /* fetch as many requests as nextreq gives us */ |
| 504 | if (http_spares->nelts > 0) { |
| 505 | sub_http = *(md_http_t **)(apr_array_pop(http_spares)); |
| 506 | } |
| 507 | else { |
| 508 | rv = md_http_clone(&sub_http, p, http); |
| 509 | if (APR_SUCCESS != rv) { |
| 510 | md_log_perror(MD_LOG_MARK, MD_LOG_ERR, rv, p, |
| 511 | "multi_perform[%d reqs]: setup failed", requests->nelts); |
| 512 | goto leave; |
| 513 | } |
| 514 | } |
| 515 | |
| 516 | rv = nextreq(&req, baton, sub_http, requests->nelts); |
| 517 | if (APR_STATUS_IS_ENOENT(rv)) { |
| 518 | md_log_perror(MD_LOG_MARK, MD_LOG_TRACE3, 0, p, |
| 519 | "multi_perform[%d reqs]: no more requests", requests->nelts); |
| 520 | if (!requests->nelts) { |
| 521 | goto leave; |
| 522 | } |
| 523 | break; |
| 524 | } |
| 525 | else if (APR_SUCCESS != rv) { |
| 526 | md_log_perror(MD_LOG_MARK, MD_LOG_TRACE3, rv, p, |
| 527 | "multi_perform[%d reqs]: nextreq() failed", requests->nelts); |
| 528 | APR_ARRAY_PUSH(http_spares, md_http_t*) = sub_http; |
| 529 | goto leave; |
| 530 | } |
| 531 | |
| 532 | if (APR_SUCCESS != (rv = internals_setup(req))) { |
| 533 | if (req->cb.on_status) req->cb.on_status(req, rv, req->cb.on_status_data); |
| 534 | md_log_perror(MD_LOG_MARK, MD_LOG_TRACE3, rv, p, |
| 535 | "multi_perform[%d reqs]: setup failed", requests->nelts); |
nothing calls this directly
no test coverage detected