| 201 | } |
| 202 | |
| 203 | static void process_alternates_response(void *callback_data) |
| 204 | { |
| 205 | struct alternates_request *alt_req = |
| 206 | (struct alternates_request *)callback_data; |
| 207 | struct walker *walker = alt_req->walker; |
| 208 | struct walker_data *cdata = walker->data; |
| 209 | struct active_request_slot *slot = alt_req->slot; |
| 210 | struct alt_base *tail = cdata->alt; |
| 211 | const char *base = alt_req->base; |
| 212 | const char null_byte = '\0'; |
| 213 | char *data; |
| 214 | int i = 0; |
| 215 | |
| 216 | normalize_curl_result(&slot->curl_result, slot->http_code, |
| 217 | curl_errorstr, sizeof(curl_errorstr)); |
| 218 | |
| 219 | if (alt_req->http_specific) { |
| 220 | if (slot->curl_result != CURLE_OK || |
| 221 | !alt_req->buffer->len) { |
| 222 | |
| 223 | /* Try reusing the slot to get non-http alternates */ |
| 224 | alt_req->http_specific = 0; |
| 225 | strbuf_reset(alt_req->url); |
| 226 | strbuf_addf(alt_req->url, "%s/objects/info/alternates", |
| 227 | base); |
| 228 | curl_easy_setopt(slot->curl, CURLOPT_URL, |
| 229 | alt_req->url->buf); |
| 230 | active_requests++; |
| 231 | slot->in_use = 1; |
| 232 | if (slot->finished) |
| 233 | (*slot->finished) = 0; |
| 234 | if (!start_active_slot(slot)) { |
| 235 | cdata->got_alternates = -1; |
| 236 | slot->in_use = 0; |
| 237 | if (slot->finished) |
| 238 | (*slot->finished) = 1; |
| 239 | } |
| 240 | return; |
| 241 | } |
| 242 | } else if (slot->curl_result != CURLE_OK) { |
| 243 | if (!missing_target(slot)) { |
| 244 | cdata->got_alternates = -1; |
| 245 | return; |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | fwrite_buffer((char *)&null_byte, 1, 1, alt_req->buffer); |
| 250 | alt_req->buffer->len--; |
| 251 | data = alt_req->buffer->buf; |
| 252 | |
| 253 | while (i < alt_req->buffer->len) { |
| 254 | int posn = i; |
| 255 | while (posn < alt_req->buffer->len && data[posn] != '\n') |
| 256 | posn++; |
| 257 | if (data[posn] == '\n') { |
| 258 | int okay = 0; |
| 259 | int serverlen = 0; |
| 260 | struct alt_base *newalt; |
nothing calls this directly
no test coverage detected