]> git.ipfire.org Git - thirdparty/git.git/blame - http-walker.c
treewide: be explicit about dependence on strbuf.h
[thirdparty/git.git] / http-walker.c
CommitLineData
b6fdc44c 1#include "git-compat-util.h"
cf78ae4f 2#include "repository.h"
6eb7ed54 3#include "commit.h"
41771fa4 4#include "hex.h"
30ae764b 5#include "walker.h"
29508e1e 6#include "http.h"
94e99012 7#include "list.h"
abcbdc03 8#include "transport.h"
d6fe0036 9#include "packfile.h"
a80d72db 10#include "object-store.h"
7baa3e86 11
9cba13ca 12struct alt_base {
2afea3bc 13 char *base;
b3661567
DB
14 int got_indices;
15 struct packed_git *packs;
16 struct alt_base *next;
17};
18
e388ab74 19enum object_request_state {
1d389ab6
NH
20 WAITING,
21 ABORTED,
22 ACTIVE,
4b05548f 23 COMPLETE
1d389ab6 24};
6eb7ed54 25
9cba13ca 26struct object_request {
30ae764b 27 struct walker *walker;
16f0705d 28 struct object_id oid;
1d389ab6 29 struct alt_base *repo;
e388ab74 30 enum object_request_state state;
5424bc55 31 struct http_object_request *req;
94e99012 32 struct list_head node;
1d389ab6
NH
33};
34
e388ab74 35struct alternates_request {
30ae764b 36 struct walker *walker;
8e29f6a0 37 const char *base;
54ba4c5f 38 struct strbuf *url;
028c2976 39 struct strbuf *buffer;
acc075a8
NH
40 struct active_request_slot *slot;
41 int http_specific;
42};
43
30ae764b
DB
44struct walker_data {
45 const char *url;
46 int got_alternates;
47 struct alt_base *alt;
30ae764b
DB
48};
49
94e99012 50static LIST_HEAD(object_queue_head);
bc8f2652 51
30ae764b 52static void fetch_alternates(struct walker *walker, const char *base);
1d389ab6 53
29508e1e 54static void process_object_response(void *callback_data);
1d389ab6 55
30ae764b
DB
56static void start_object_request(struct walker *walker,
57 struct object_request *obj_req)
1d389ab6 58{
1d389ab6 59 struct active_request_slot *slot;
5424bc55 60 struct http_object_request *req;
1d389ab6 61
f0be0db1 62 req = new_http_object_request(obj_req->repo->base, &obj_req->oid);
afe8a907 63 if (!req) {
e388ab74 64 obj_req->state = ABORTED;
1d389ab6
NH
65 return;
66 }
5424bc55 67 obj_req->req = req;
1d389ab6 68
5424bc55 69 slot = req->slot;
29508e1e 70 slot->callback_func = process_object_response;
e388ab74 71 slot->callback_data = obj_req;
1d389ab6 72
a7a8d378 73 /* Try to get the request started, abort the request on error */
e388ab74 74 obj_req->state = ACTIVE;
1d389ab6 75 if (!start_active_slot(slot)) {
e388ab74 76 obj_req->state = ABORTED;
5424bc55 77 release_http_object_request(req);
e388ab74 78 return;
1d389ab6 79 }
1d389ab6
NH
80}
81
e388ab74 82static void finish_object_request(struct object_request *obj_req)
1d389ab6 83{
5424bc55 84 if (finish_http_object_request(obj_req->req))
1d389ab6 85 return;
1d389ab6 86
5424bc55 87 if (obj_req->req->rename == 0)
16f0705d 88 walker_say(obj_req->walker, "got %s\n", oid_to_hex(&obj_req->oid));
1d389ab6
NH
89}
90
29508e1e
NH
91static void process_object_response(void *callback_data)
92{
e388ab74
NH
93 struct object_request *obj_req =
94 (struct object_request *)callback_data;
30ae764b
DB
95 struct walker *walker = obj_req->walker;
96 struct walker_data *data = walker->data;
97 struct alt_base *alt = data->alt;
29508e1e 98
5424bc55 99 process_http_object_request(obj_req->req);
e388ab74 100 obj_req->state = COMPLETE;
29508e1e 101
ccbbd8bf
JK
102 normalize_curl_result(&obj_req->req->curl_result,
103 obj_req->req->http_code,
104 obj_req->req->errorstr,
105 sizeof(obj_req->req->errorstr));
106
29508e1e 107 /* Use alternates if necessary */
5424bc55 108 if (missing_target(obj_req->req)) {
30ae764b 109 fetch_alternates(walker, alt->base);
afe8a907 110 if (obj_req->repo->next) {
e388ab74
NH
111 obj_req->repo =
112 obj_req->repo->next;
5424bc55 113 release_http_object_request(obj_req->req);
30ae764b 114 start_object_request(walker, obj_req);
29508e1e
NH
115 return;
116 }
117 }
118
e388ab74 119 finish_object_request(obj_req);
29508e1e
NH
120}
121
e388ab74 122static void release_object_request(struct object_request *obj_req)
1d389ab6 123{
5424bc55
TRC
124 if (obj_req->req !=NULL && obj_req->req->localfile != -1)
125 error("fd leakage in release: %d", obj_req->req->localfile);
1d389ab6 126
94e99012 127 list_del(&obj_req->node);
e388ab74 128 free(obj_req);
1d389ab6
NH
129}
130
30ae764b 131static int fill_active_slot(struct walker *walker)
1d389ab6 132{
45c17412 133 struct object_request *obj_req;
94e99012 134 struct list_head *pos, *tmp, *head = &object_queue_head;
1d389ab6 135
94e99012
EW
136 list_for_each_safe(pos, tmp, head) {
137 obj_req = list_entry(pos, struct object_request, node);
e388ab74 138 if (obj_req->state == WAITING) {
bc726bd0 139 if (repo_has_object_file(the_repository, &obj_req->oid))
09db444f 140 obj_req->state = COMPLETE;
45c17412 141 else {
30ae764b 142 start_object_request(walker, obj_req);
45c17412
DB
143 return 1;
144 }
f1a906a3 145 }
8fcf7f9a 146 }
45c17412 147 return 0;
1d389ab6
NH
148}
149
30ae764b 150static void prefetch(struct walker *walker, unsigned char *sha1)
1d389ab6 151{
e388ab74 152 struct object_request *newreq;
30ae764b 153 struct walker_data *data = walker->data;
1d389ab6
NH
154
155 newreq = xmalloc(sizeof(*newreq));
30ae764b 156 newreq->walker = walker;
92e2cab9 157 oidread(&newreq->oid, sha1);
30ae764b 158 newreq->repo = data->alt;
1d389ab6 159 newreq->state = WAITING;
5424bc55 160 newreq->req = NULL;
1d389ab6 161
e9176745 162 http_is_verbose = walker->get_verbosely;
94e99012 163 list_add_tail(&newreq->node, &object_queue_head);
29508e1e 164
29508e1e
NH
165 fill_active_slots();
166 step_active_slots();
1d389ab6
NH
167}
168
abcbdc03
JK
169static int is_alternate_allowed(const char *url)
170{
171 const char *protocols[] = {
172 "http", "https", "ftp", "ftps"
173 };
174 int i;
175
de461388
EW
176 if (http_follow_config != HTTP_FOLLOW_ALWAYS) {
177 warning("alternate disabled by http.followRedirects: %s", url);
178 return 0;
179 }
180
abcbdc03
JK
181 for (i = 0; i < ARRAY_SIZE(protocols); i++) {
182 const char *end;
183 if (skip_prefix(url, protocols[i], &end) &&
184 starts_with(end, "://"))
185 break;
186 }
187
188 if (i >= ARRAY_SIZE(protocols)) {
189 warning("ignoring alternate with unknown protocol: %s", url);
190 return 0;
191 }
192 if (!is_transport_allowed(protocols[i], 0)) {
193 warning("ignoring alternate with restricted protocol: %s", url);
194 return 0;
195 }
196
197 return 1;
198}
199
e388ab74 200static void process_alternates_response(void *callback_data)
b3661567 201{
e388ab74
NH
202 struct alternates_request *alt_req =
203 (struct alternates_request *)callback_data;
30ae764b
DB
204 struct walker *walker = alt_req->walker;
205 struct walker_data *cdata = walker->data;
acc075a8 206 struct active_request_slot *slot = alt_req->slot;
30ae764b 207 struct alt_base *tail = cdata->alt;
8e29f6a0 208 const char *base = alt_req->base;
a04ff3ec 209 const char null_byte = '\0';
acc075a8
NH
210 char *data;
211 int i = 0;
1d389ab6 212
ccbbd8bf
JK
213 normalize_curl_result(&slot->curl_result, slot->http_code,
214 curl_errorstr, sizeof(curl_errorstr));
215
acc075a8
NH
216 if (alt_req->http_specific) {
217 if (slot->curl_result != CURLE_OK ||
028c2976 218 !alt_req->buffer->len) {
acc075a8
NH
219
220 /* Try reusing the slot to get non-http alternates */
221 alt_req->http_specific = 0;
54ba4c5f
JK
222 strbuf_reset(alt_req->url);
223 strbuf_addf(alt_req->url, "%s/objects/info/alternates",
224 base);
acc075a8 225 curl_easy_setopt(slot->curl, CURLOPT_URL,
54ba4c5f 226 alt_req->url->buf);
acc075a8
NH
227 active_requests++;
228 slot->in_use = 1;
afe8a907 229 if (slot->finished)
c9826473 230 (*slot->finished) = 0;
a3f583cb 231 if (!start_active_slot(slot)) {
30ae764b 232 cdata->got_alternates = -1;
29508e1e 233 slot->in_use = 0;
afe8a907 234 if (slot->finished)
c9826473 235 (*slot->finished) = 1;
1d389ab6 236 }
a3f583cb 237 return;
b3661567 238 }
acc075a8 239 } else if (slot->curl_result != CURLE_OK) {
be4a015b 240 if (!missing_target(slot)) {
30ae764b 241 cdata->got_alternates = -1;
acc075a8
NH
242 return;
243 }
b3661567
DB
244 }
245
a04ff3ec 246 fwrite_buffer((char *)&null_byte, 1, 1, alt_req->buffer);
028c2976
MH
247 alt_req->buffer->len--;
248 data = alt_req->buffer->buf;
1b0c1e67 249
028c2976 250 while (i < alt_req->buffer->len) {
b3661567 251 int posn = i;
028c2976 252 while (posn < alt_req->buffer->len && data[posn] != '\n')
b3661567
DB
253 posn++;
254 if (data[posn] == '\n') {
1b0c1e67
DB
255 int okay = 0;
256 int serverlen = 0;
257 struct alt_base *newalt;
b3661567 258 if (data[i] == '/') {
4c42aa1a
TRC
259 /*
260 * This counts
5df1e0d0
JH
261 * http://git.host/pub/scm/linux.git/
262 * -----------here^
263 * so memcpy(dst, base, serverlen) will
264 * copy up to "...git.host".
265 */
266 const char *colon_ss = strstr(base,"://");
267 if (colon_ss) {
268 serverlen = (strchr(colon_ss + 3, '/')
269 - base);
270 okay = 1;
271 }
1b0c1e67 272 } else if (!memcmp(data + i, "../", 3)) {
4c42aa1a
TRC
273 /*
274 * Relative URL; chop the corresponding
5df1e0d0
JH
275 * number of subpath from base (and ../
276 * from data), and concatenate the result.
277 *
278 * The code first drops ../ from data, and
279 * then drops one ../ from data and one path
280 * from base. IOW, one extra ../ is dropped
281 * from data than path is dropped from base.
282 *
283 * This is not wrong. The alternate in
284 * http://git.host/pub/scm/linux.git/
285 * to borrow from
286 * http://git.host/pub/scm/linus.git/
287 * is ../../linus.git/objects/. You need
288 * two ../../ to borrow from your direct
289 * neighbour.
290 */
1b0c1e67
DB
291 i += 3;
292 serverlen = strlen(base);
8fcf7f9a 293 while (i + 2 < posn &&
1b0c1e67
DB
294 !memcmp(data + i, "../", 3)) {
295 do {
296 serverlen--;
297 } while (serverlen &&
298 base[serverlen - 1] != '/');
299 i += 3;
300 }
a9486b02 301 /* If the server got removed, give up. */
8fcf7f9a 302 okay = strchr(base, ':') - base + 3 <
4c42aa1a 303 serverlen;
acc075a8 304 } else if (alt_req->http_specific) {
1b0c1e67
DB
305 char *colon = strchr(data + i, ':');
306 char *slash = strchr(data + i, '/');
307 if (colon && slash && colon < data + posn &&
308 slash < data + posn && colon < slash) {
309 okay = 1;
310 }
311 }
1b0c1e67 312 if (okay) {
59b8263a
RS
313 struct strbuf target = STRBUF_INIT;
314 strbuf_add(&target, base, serverlen);
d61434ae
JK
315 strbuf_add(&target, data + i, posn - i);
316 if (!strbuf_strip_suffix(&target, "objects")) {
317 warning("ignoring alternate that does"
318 " not end in 'objects': %s",
319 target.buf);
320 strbuf_release(&target);
321 } else if (is_alternate_allowed(target.buf)) {
abcbdc03
JK
322 warning("adding alternate object store: %s",
323 target.buf);
324 newalt = xmalloc(sizeof(*newalt));
325 newalt->next = NULL;
326 newalt->base = strbuf_detach(&target, NULL);
327 newalt->got_indices = 0;
328 newalt->packs = NULL;
329
330 while (tail->next != NULL)
331 tail = tail->next;
332 tail->next = newalt;
5cae73d5
EW
333 } else {
334 strbuf_release(&target);
abcbdc03 335 }
b3661567
DB
336 }
337 }
338 i = posn + 1;
339 }
bc8f2652 340
30ae764b 341 cdata->got_alternates = 1;
acc075a8
NH
342}
343
30ae764b 344static void fetch_alternates(struct walker *walker, const char *base)
acc075a8 345{
028c2976 346 struct strbuf buffer = STRBUF_INIT;
54ba4c5f 347 struct strbuf url = STRBUF_INIT;
acc075a8 348 struct active_request_slot *slot;
cb754fdf 349 struct alternates_request alt_req;
30ae764b 350 struct walker_data *cdata = walker->data;
acc075a8 351
4c42aa1a
TRC
352 /*
353 * If another request has already started fetching alternates,
354 * wait for them to arrive and return to processing this request's
355 * curl message
356 */
30ae764b 357 while (cdata->got_alternates == 0) {
29508e1e 358 step_active_slots();
acc075a8
NH
359 }
360
361 /* Nothing to do if they've already been fetched */
30ae764b 362 if (cdata->got_alternates == 1)
acc075a8
NH
363 return;
364
365 /* Start the fetch */
30ae764b 366 cdata->got_alternates = 0;
acc075a8 367
30ae764b 368 if (walker->get_verbosely)
acc075a8 369 fprintf(stderr, "Getting alternates list for %s\n", base);
8fcf7f9a 370
54ba4c5f 371 strbuf_addf(&url, "%s/objects/info/http-alternates", base);
acc075a8 372
4c42aa1a
TRC
373 /*
374 * Use a callback to process the result, since another request
375 * may fail and need to have alternates loaded before continuing
376 */
acc075a8 377 slot = get_active_slot();
e388ab74 378 slot->callback_func = process_alternates_response;
30ae764b 379 alt_req.walker = walker;
acc075a8
NH
380 slot->callback_data = &alt_req;
381
8dda4cbd 382 curl_easy_setopt(slot->curl, CURLOPT_WRITEDATA, &buffer);
29508e1e 383 curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, fwrite_buffer);
54ba4c5f 384 curl_easy_setopt(slot->curl, CURLOPT_URL, url.buf);
acc075a8
NH
385
386 alt_req.base = base;
54ba4c5f 387 alt_req.url = &url;
acc075a8
NH
388 alt_req.buffer = &buffer;
389 alt_req.http_specific = 1;
390 alt_req.slot = slot;
391
392 if (start_active_slot(slot))
393 run_active_slot(slot);
394 else
30ae764b 395 cdata->got_alternates = -1;
acc075a8 396
028c2976 397 strbuf_release(&buffer);
54ba4c5f 398 strbuf_release(&url);
b3661567
DB
399}
400
30ae764b 401static int fetch_indices(struct walker *walker, struct alt_base *repo)
182005b9 402{
b8caac2b 403 int ret;
1d389ab6 404
b3661567 405 if (repo->got_indices)
182005b9
DB
406 return 0;
407
30ae764b 408 if (walker->get_verbosely)
6fd72e39 409 fprintf(stderr, "Getting pack list for %s\n", repo->base);
8fcf7f9a 410
b8caac2b
TRC
411 switch (http_get_info_packs(repo->base, &repo->packs)) {
412 case HTTP_OK:
413 case HTTP_MISSING_TARGET:
414 repo->got_indices = 1;
415 ret = 0;
416 break;
417 default:
5e3a7691 418 repo->got_indices = 0;
b8caac2b 419 ret = -1;
b3661567 420 }
182005b9 421
3a462bc9 422 return ret;
182005b9
DB
423}
424
07c19e72 425static int http_fetch_pack(struct walker *walker, struct alt_base *repo, unsigned char *sha1)
182005b9 426{
182005b9 427 struct packed_git *target;
49a0f240 428 int ret;
cb754fdf 429 struct slot_results results;
2264dfa5 430 struct http_pack_request *preq;
182005b9 431
30ae764b 432 if (fetch_indices(walker, repo))
182005b9 433 return -1;
b3661567 434 target = find_sha1_pack(sha1, repo->packs);
182005b9 435 if (!target)
b3661567 436 return -1;
eb053492 437 close_pack_index(target);
182005b9 438
30ae764b 439 if (walker->get_verbosely) {
182005b9 440 fprintf(stderr, "Getting pack %s\n",
2bf1db78 441 hash_to_hex(target->hash));
182005b9 442 fprintf(stderr, " which contains %s\n",
2bf1db78 443 hash_to_hex(sha1));
182005b9
DB
444 }
445
eb053492 446 preq = new_http_pack_request(target->hash, repo->base);
afe8a907 447 if (!preq)
2264dfa5 448 goto abort;
2264dfa5 449 preq->slot->results = &results;
182005b9 450
2264dfa5
TRC
451 if (start_active_slot(preq->slot)) {
452 run_active_slot(preq->slot);
c8568e13 453 if (results.curl_result != CURLE_OK) {
2264dfa5
TRC
454 error("Unable to get pack file %s\n%s", preq->url,
455 curl_errorstr);
456 goto abort;
1d389ab6
NH
457 }
458 } else {
2264dfa5
TRC
459 error("Unable to start request");
460 goto abort;
182005b9
DB
461 }
462
2264dfa5
TRC
463 ret = finish_http_pack_request(preq);
464 release_http_pack_request(preq);
49a0f240 465 if (ret)
b721e01f 466 return ret;
eb053492 467 http_install_packfile(target, &repo->packs);
49a0f240 468
182005b9 469 return 0;
2264dfa5
TRC
470
471abort:
472 return -1;
182005b9
DB
473}
474
53f31389
MW
475static void abort_object_request(struct object_request *obj_req)
476{
53f31389
MW
477 release_object_request(obj_req);
478}
479
2bf1db78 480static int fetch_object(struct walker *walker, unsigned char *hash)
6eb7ed54 481{
2bf1db78 482 char *hex = hash_to_hex(hash);
29508e1e 483 int ret = 0;
94e99012 484 struct object_request *obj_req = NULL;
5424bc55 485 struct http_object_request *req;
94e99012 486 struct list_head *pos, *head = &object_queue_head;
1d389ab6 487
94e99012
EW
488 list_for_each(pos, head) {
489 obj_req = list_entry(pos, struct object_request, node);
2bf1db78 490 if (hasheq(obj_req->oid.hash, hash))
94e99012
EW
491 break;
492 }
afe8a907 493 if (!obj_req)
1d389ab6
NH
494 return error("Couldn't find request for %s in the queue", hex);
495
bc726bd0 496 if (repo_has_object_file(the_repository, &obj_req->oid)) {
afe8a907 497 if (obj_req->req)
5424bc55 498 abort_http_object_request(obj_req->req);
53f31389 499 abort_object_request(obj_req);
11f0dafe
NH
500 return 0;
501 }
502
4c42aa1a 503 while (obj_req->state == WAITING)
29508e1e 504 step_active_slots();
6eb7ed54 505
5424bc55
TRC
506 /*
507 * obj_req->req might change when fetching alternates in the callback
508 * process_object_response; therefore, the "shortcut" variable, req,
509 * is used only after we're done with slots.
510 */
4c42aa1a 511 while (obj_req->state == ACTIVE)
5424bc55
TRC
512 run_active_slot(obj_req->req->slot);
513
514 req = obj_req->req;
4c42aa1a 515
5424bc55
TRC
516 if (req->localfile != -1) {
517 close(req->localfile);
518 req->localfile = -1;
313c4714 519 }
6eb7ed54 520
3d10f72e
JK
521 normalize_curl_result(&req->curl_result, req->http_code,
522 req->errorstr, sizeof(req->errorstr));
17966c0a 523
e388ab74 524 if (obj_req->state == ABORTED) {
29508e1e 525 ret = error("Request for %s aborted", hex);
5424bc55
TRC
526 } else if (req->curl_result != CURLE_OK &&
527 req->http_code != 416) {
528 if (missing_target(req))
e2029eb9
PB
529 ret = -1; /* Be silent, it is probably in a pack. */
530 else
531 ret = error("%s (curl_result = %d, http_code = %ld, sha1 = %s)",
5424bc55
TRC
532 req->errorstr, req->curl_result,
533 req->http_code, hex);
534 } else if (req->zret != Z_STREAM_END) {
30ae764b 535 walker->corrupt_object_found++;
5424bc55 536 ret = error("File %s (%s) corrupt", hex, req->url);
f0be0db1 537 } else if (!oideq(&obj_req->oid, &req->real_oid)) {
bd2afde8 538 ret = error("File %s has bad hash", hex);
5424bc55 539 } else if (req->rename < 0) {
ea657730 540 struct strbuf buf = STRBUF_INIT;
514c5fdd 541 loose_object_path(the_repository, &buf, &req->oid);
ea657730
CC
542 ret = error("unable to write sha1 filename %s", buf.buf);
543 strbuf_release(&buf);
6eb7ed54 544 }
49a0f240 545
5424bc55 546 release_http_object_request(req);
e388ab74 547 release_object_request(obj_req);
29508e1e 548 return ret;
6eb7ed54
DB
549}
550
2bf1db78 551static int fetch(struct walker *walker, unsigned char *hash)
b3661567 552{
30ae764b
DB
553 struct walker_data *data = walker->data;
554 struct alt_base *altbase = data->alt;
1d389ab6 555
2bf1db78 556 if (!fetch_object(walker, hash))
1d389ab6 557 return 0;
b3661567 558 while (altbase) {
2bf1db78 559 if (!http_fetch_pack(walker, altbase, hash))
b3661567 560 return 0;
30ae764b 561 fetch_alternates(walker, data->alt->base);
b3661567
DB
562 altbase = altbase->next;
563 }
2bf1db78 564 return error("Unable to find %s under %s", hash_to_hex(hash),
30ae764b 565 data->alt->base);
b3661567
DB
566}
567
c13b2633 568static int fetch_ref(struct walker *walker, struct ref *ref)
cd541a68 569{
30ae764b 570 struct walker_data *data = walker->data;
c13b2633 571 return http_fetch_ref(data->alt->base, ref);
cd541a68
DB
572}
573
30ae764b
DB
574static void cleanup(struct walker *walker)
575{
09ae9aca
TRC
576 struct walker_data *data = walker->data;
577 struct alt_base *alt, *alt_next;
578
579 if (data) {
580 alt = data->alt;
581 while (alt) {
582 alt_next = alt->next;
583
584 free(alt->base);
585 free(alt);
586
587 alt = alt_next;
588 }
589 free(data);
590 walker->data = NULL;
591 }
30ae764b
DB
592}
593
888692b7 594struct walker *get_http_walker(const char *url)
6eb7ed54 595{
9c880b3e 596 char *s;
30ae764b
DB
597 struct walker_data *data = xmalloc(sizeof(struct walker_data));
598 struct walker *walker = xmalloc(sizeof(struct walker));
6eb7ed54 599
30ae764b 600 data->alt = xmalloc(sizeof(*data->alt));
95244ae3 601 data->alt->base = xstrdup(url);
30ae764b 602 for (s = data->alt->base + strlen(data->alt->base) - 1; *s == '/'; --s)
9c880b3e 603 *s = 0;
6eb7ed54 604
30ae764b
DB
605 data->alt->got_indices = 0;
606 data->alt->packs = NULL;
607 data->alt->next = NULL;
608 data->got_alternates = -1;
fc57b6aa 609
30ae764b
DB
610 walker->corrupt_object_found = 0;
611 walker->fetch = fetch;
612 walker->fetch_ref = fetch_ref;
613 walker->prefetch = prefetch;
614 walker->cleanup = cleanup;
615 walker->data = data;
6eb7ed54 616
30ae764b 617 add_fill_function(walker, (int (*)(void *)) fill_active_slot);
8e29f6a0 618
30ae764b 619 return walker;
6eb7ed54 620}