Commit Diff


commit - aabb25f81b1f8f68a03af422f9ae14ea5c3ae1fd
commit + cae60ab8f2a261b006b3ccbded2d53dccbd6f300
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 - 5c304b81b40e2f353d56b5acb1e76b45f3448678
blob + c3e801e9c0d7b67f66bf77579aba98535cf054db
--- 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 - 5180371c65007227a78d76ba0d4b63cd2ee65675
blob + a08374f7b103b4078c61a1872a293f454f078ec4
--- lib/pack_create_privsep.c
+++ lib/pack_create_privsep.c
@@ -26,6 +26,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
+#include <time.h>
 #include <imsg.h>
 #include <inttypes.h>
 #include <unistd.h>
@@ -42,6 +43,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 - d6850e32bdb9622e2e43e0854788c80dadefc6a9
blob + 8486282d50b2fc83c3f3b444373cd17540fd31dd
--- lib/repository_admin.c
+++ lib/repository_admin.c
@@ -51,10 +51,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]))
@@ -155,10 +155,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");
@@ -207,7 +210,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 - 999423dd36a6b128a64253ae2261a4d4aadb3796
blob + f916422dab87523c5b073b161f9ba85ad2f970b2
--- lib/send.c
+++ lib/send.c
@@ -64,6 +64,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"
 
@@ -640,12 +641,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;