Commit Diff


commit - 0136599f8fc0aa5d26834c46a9b9feb48d12c726
commit + 713d6e1144f1c1a21dd9013eab0cdf75a6b01ab8
blob - 4ccb85602edfc0c368dc34ae06bdbbb56e4c04c8
blob + 5a2aab6936ab69339d4222d09c60d58f421d067c
--- lib/got_lib_pack_index.h
+++ lib/got_lib_pack_index.h
@@ -21,4 +21,5 @@ const struct got_error *
 got_pack_index(struct got_pack *pack, int idxfd,
     FILE *tmpfile, FILE *delta_base_file, FILE *delta_accum_file,
     uint8_t *pack_sha1_expected,
-    got_pack_index_progress_cb progress_cb, void *progress_arg);
+    got_pack_index_progress_cb progress_cb, void *progress_arg,
+    struct got_ratelimit *rl);
blob - 16dba396458c110a7862ab44e90a0b8da95e14c9
blob + d0b713ea9964a6d53335b7f910b6143346ea77e3
--- lib/pack_index.c
+++ lib/pack_index.c
@@ -611,7 +611,8 @@ report_progress(int nobj_total, int nobj_indexed, int 
 const struct got_error *
 got_pack_index(struct got_pack *pack, int idxfd, FILE *tmpfile,
     FILE *delta_base_file, FILE *delta_accum_file, uint8_t *pack_sha1_expected,
-    got_pack_index_progress_cb progress_cb, void *progress_arg)
+    got_pack_index_progress_cb progress_cb, void *progress_arg,
+    struct got_ratelimit *rl)
 {
 	const struct got_error *err;
 	struct got_packfile_hdr hdr;
@@ -627,7 +628,6 @@ got_pack_index(struct got_pack *pack, int idxfd, FILE 
 	size_t mapoff = 0;
 	int p_indexed = 0, last_p_indexed = -1;
 	int p_resolved = 0, last_p_resolved = -1;
-	struct got_ratelimit rl;
 
 	/* Require that pack file header and SHA1 trailer are present. */
 	if (pack->filesize < sizeof(hdr) + SHA1_DIGEST_LENGTH)
@@ -714,8 +714,6 @@ got_pack_index(struct got_pack *pack, int idxfd, FILE 
 	objects = calloc(nobj, sizeof(struct got_indexed_object));
 	if (objects == NULL)
 		return got_error_from_errno("calloc");
-
-	got_ratelimit_init(&rl, 0, 500);
 
 	/*
 	 * First pass: locate all objects and identify un-deltified objects.
@@ -731,7 +729,7 @@ got_pack_index(struct got_pack *pack, int idxfd, FILE 
 		p_indexed = ((i + 1) * 100) / nobj;
 		if (p_indexed != last_p_indexed) {
 			err = report_progress(nobj, i + 1, nloose, 0,
-			    &rl, progress_cb, progress_arg);
+			    rl, progress_cb, progress_arg);
 			if (err)
 				goto done;
 			last_p_indexed = p_indexed;
@@ -876,7 +874,7 @@ got_pack_index(struct got_pack *pack, int idxfd, FILE 
 			p_resolved = ((nresolved + n) * 100) / nobj;
 			if (p_resolved != last_p_resolved) {
 				err = report_progress(nobj, nobj,
-				    nloose, nresolved + n, &rl,
+				    nloose, nresolved + n, rl,
 				    progress_cb, progress_arg);
 				if (err)
 					goto done;
blob - 415bece3cfad5111141beafea7174da537536853
blob + 5e1cdd91604197f387a69d438c81d9d7787bb0d2
--- libexec/got-index-pack/got-index-pack.c
+++ libexec/got-index-pack/got-index-pack.c
@@ -85,12 +85,15 @@ main(int argc, char **argv)
 	struct got_pack pack;
 	uint8_t pack_hash[SHA1_DIGEST_LENGTH];
 	off_t packfile_size;
+	struct got_ratelimit rl;
 #if 0
 	static int attached;
 	while (!attached)
 		sleep(1);
 #endif
 
+	got_ratelimit_init(&rl, 0, 500);
+
 	for (i = 0; i < nitems(tmpfiles); i++)
 		tmpfiles[i] = NULL;
 
@@ -185,8 +188,8 @@ main(int argc, char **argv)
 	if (pack.map == MAP_FAILED)
 		pack.map = NULL; /* fall back to read(2) */
 #endif
-	err = got_pack_index(&pack, idxfd, tmpfiles[0], tmpfiles[1], tmpfiles[2],
-	    pack_hash, send_index_pack_progress, &ibuf);
+	err = got_pack_index(&pack, idxfd, tmpfiles[0], tmpfiles[1],
+	    tmpfiles[2], pack_hash, send_index_pack_progress, &ibuf, &rl);
 done:
 	close_err = got_pack_close(&pack);
 	if (close_err && err == NULL)