Commit Diff


commit - 723ed5ad7b6b4e64fb94f1b356e4cfbf4c86edac
commit + abd468944be5280ec9e2019af467e1602492eea7
blob - eccf16c525cb2cec8d54d8ed5220540f001ddb78
blob + 7ad544d7095d79e959a67e5c9d4d84fd6da2c0f4
--- lib/got_lib_pack_create.h
+++ lib/got_lib_pack_create.h
@@ -26,7 +26,7 @@ const struct got_error *got_pack_create(uint8_t *pack_
     struct got_object_id **ours, int nours,
     struct got_repository *repo, int loose_obj_only, int allow_empty,
     got_pack_progress_cb progress_cb, void *progress_arg,
-    got_cancel_cb cancel_cb, void *cancel_arg);
+    struct got_ratelimit *, got_cancel_cb cancel_cb, void *cancel_arg);
 
 const struct got_error *
 got_pack_cache_pack_for_packidx(struct got_pack **pack,
blob - fa24d6789b4671eefef1cf2118459acc4c7dcb94
blob + 24c0a5e34236fc8bf13c51f4a647434a80f2cb21
--- lib/pack_create.c
+++ lib/pack_create.c
@@ -50,10 +50,10 @@
 #include "got_lib_object_idset.h"
 #include "got_lib_object_cache.h"
 #include "got_lib_deflate.h"
+#include "got_lib_ratelimit.h"
 #include "got_lib_pack.h"
 #include "got_lib_pack_create.h"
 #include "got_lib_repository.h"
-#include "got_lib_ratelimit.h"
 #include "got_lib_inflate.h"
 
 #include "murmurhash2.h"
@@ -1826,12 +1826,11 @@ got_pack_create(uint8_t *packsha1, int packfd, FILE *d
     struct got_object_id **ours, int nours,
     struct got_repository *repo, int loose_obj_only, int allow_empty,
     got_pack_progress_cb progress_cb, void *progress_arg,
-    got_cancel_cb cancel_cb, void *cancel_arg)
+    struct got_ratelimit *rl, got_cancel_cb cancel_cb, void *cancel_arg)
 {
 	const struct got_error *err;
 	int delta_cache_fd = -1;
 	struct got_object_idset *idset;
-	struct got_ratelimit rl;
 	struct got_pack_metavec deltify, reuse;
 	int ncolored = 0, nfound = 0, ntrees = 0;
 	size_t ndeltify;
@@ -1842,15 +1841,13 @@ got_pack_create(uint8_t *packsha1, int packfd, FILE *d
 	memset(&deltify, 0, sizeof(deltify));
 	memset(&reuse, 0, sizeof(reuse));
 
-	got_ratelimit_init(&rl, 0, 500);
-
 	idset = got_object_idset_alloc();
 	if (idset == NULL)
 		return got_error_from_errno("got_object_idset_alloc");
 
 	err = load_object_ids(&ncolored, &nfound, &ntrees, idset, theirs,
 	    ntheirs, ours, nours, repo, seed, loose_obj_only,
-	    progress_cb, progress_arg, &rl, cancel_cb, cancel_arg);
+	    progress_cb, progress_arg, rl, cancel_cb, cancel_arg);
 	if (err)
 		goto done;
 
@@ -1882,7 +1879,7 @@ got_pack_create(uint8_t *packsha1, int packfd, FILE *d
 
 	err = got_pack_search_deltas(&reuse, idset, delta_cache_fd,
 	    ncolored, nfound, ntrees, nours,
-	    repo, progress_cb, progress_arg, &rl, cancel_cb, cancel_arg);
+	    repo, progress_cb, progress_arg, rl, cancel_cb, cancel_arg);
 	if (err)
 		goto done;
 
@@ -1907,7 +1904,7 @@ got_pack_create(uint8_t *packsha1, int packfd, FILE *d
 		if (deltify.nmeta > 0) {
 			err = pick_deltas(deltify.meta, deltify.nmeta,
 			    ncolored, nfound, ntrees, nours, reuse.nmeta,
-			    delta_cache, repo, progress_cb, progress_arg, &rl,
+			    delta_cache, repo, progress_cb, progress_arg, rl,
 			    cancel_cb, cancel_arg);
 			if (err)
 				goto done;
@@ -1920,7 +1917,7 @@ got_pack_create(uint8_t *packsha1, int packfd, FILE *d
 	}
 	err = genpack(packsha1, packfd, delta_cache, deltify.meta,
 	    deltify.nmeta, reuse.meta, reuse.nmeta, ncolored, nfound, ntrees,
-	    nours, repo, progress_cb, progress_arg, &rl,
+	    nours, repo, progress_cb, progress_arg, rl,
 	    cancel_cb, cancel_arg);
 	if (err)
 		goto done;
blob - 03b3bf4d95c05ee2ffee2dab58e9f3ec47a22108
blob + 5208c69156b4a16a0a67232b7ed94cfdc354678b
--- lib/pack_create_privsep.c
+++ lib/pack_create_privsep.c
@@ -24,6 +24,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
+#include <time.h>
 #include <imsg.h>
 #include <inttypes.h>
 #include <unistd.h>
@@ -40,6 +41,7 @@
 #include "got_lib_object_cache.h"
 #include "got_lib_object_idset.h"
 #include "got_lib_privsep.h"
+#include "got_lib_ratelimit.h"
 #include "got_lib_pack.h"
 #include "got_lib_pack_create.h"
 #include "got_lib_repository.h"
blob - eb6585d23d5e69a331cdd167993f02218ad95c59
blob + 600aae154a6488a127d0f703ea93de4a403dfa9a
--- lib/repository_admin.c
+++ lib/repository_admin.c
@@ -47,10 +47,10 @@
 #include "got_lib_pack.h"
 #include "got_lib_privsep.h"
 #include "got_lib_repository.h"
+#include "got_lib_ratelimit.h"
 #include "got_lib_pack_create.h"
 #include "got_lib_sha1.h"
 #include "got_lib_lockfile.h"
-#include "got_lib_ratelimit.h"
 
 #ifndef nitems
 #define nitems(_a)	(sizeof((_a)) / sizeof((_a)[0]))
@@ -151,10 +151,13 @@ got_repo_pack_objects(FILE **packfile, struct got_obje
 	char *tmpfile_path = NULL, *path = NULL, *packfile_path = NULL;
 	char *sha1_str = NULL;
 	FILE *delta_cache = NULL;
+	struct got_ratelimit rl;
 
 	*packfile = NULL;
 	*pack_hash = NULL;
 
+	got_ratelimit_init(&rl, 0, 500);
+
 	if (asprintf(&path, "%s/%s/packing.pack",
 	    got_repo_get_path_git_dir(repo), GOT_OBJECTS_PACK_DIR) == -1) {
 		err = got_error_from_errno("asprintf");
@@ -203,7 +206,7 @@ got_repo_pack_objects(FILE **packfile, struct got_obje
 
 	err = got_pack_create((*pack_hash)->sha1, packfd, delta_cache,
 	    theirs, ntheirs, ours, nours, repo, loose_obj_only, 0,
-	    progress_cb, progress_arg, cancel_cb, cancel_arg);
+	    progress_cb, progress_arg, &rl, cancel_cb, cancel_arg);
 	if (err)
 		goto done;
 
blob - 981cc70c23c162d4407ab1f084af60b80cbdb0bf
blob + e2c9a83e2c62b08256e2396c00578d4f47c9aa35
--- lib/send.c
+++ lib/send.c
@@ -59,6 +59,7 @@
 #include "got_lib_privsep.h"
 #include "got_lib_object_cache.h"
 #include "got_lib_repository.h"
+#include "got_lib_ratelimit.h"
 #include "got_lib_pack_create.h"
 #include "got_lib_dial.h"
 
@@ -635,12 +636,14 @@ got_send_pack(const char *remote_name, struct got_path
 	}
 
 	if (refs_to_send > 0) {
+		struct got_ratelimit rl;
+		got_ratelimit_init(&rl, 0, 500);
 		memset(&ppa, 0, sizeof(ppa));
 		ppa.progress_cb = progress_cb;
 		ppa.progress_arg = progress_arg;
 		err = got_pack_create(packsha1, packfd, delta_cache,
 		    their_ids, ntheirs, our_ids, nours, repo, 0, 1,
-		    pack_progress, &ppa, cancel_cb, cancel_arg);
+		    pack_progress, &ppa, &rl, cancel_cb, cancel_arg);
 		if (err)
 			goto done;