[PATCH v1 4/8] odb-remote: implement odb_remote_get_many_direct()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This function will be used to get many objects from a promisor
remote.

Signed-off-by: Christian Couder <chriscool@xxxxxxxxxxxxx>
---
 odb-helper.c | 15 +++++++++++++++
 odb-helper.h |  3 +++
 odb-remote.c | 17 +++++++++++++++++
 odb-remote.h |  1 +
 4 files changed, 36 insertions(+)

diff --git a/odb-helper.c b/odb-helper.c
index 2851fe2657..5fe37e6fe5 100644
--- a/odb-helper.c
+++ b/odb-helper.c
@@ -28,3 +28,18 @@ int odb_helper_get_direct(struct odb_helper *o,
 
 	return res;
 }
+
+int odb_helper_get_many_direct(struct odb_helper *o,
+			       const struct oid_array *to_get)
+{
+	int res;
+	uint64_t start;
+
+	start = getnanotime();
+
+	res = fetch_objects(o->dealer, to_get);
+
+	trace_performance_since(start, "odb_helper_get_many_direct");
+
+	return res;
+}
diff --git a/odb-helper.h b/odb-helper.h
index d21b625a7e..d63210d516 100644
--- a/odb-helper.h
+++ b/odb-helper.h
@@ -11,4 +11,7 @@ struct odb_helper {
 extern struct odb_helper *odb_helper_new(const char *name, int namelen);
 extern int odb_helper_get_direct(struct odb_helper *o,
 				 const unsigned char *sha1);
+extern int odb_helper_get_many_direct(struct odb_helper *o,
+				      const struct oid_array *to_get);
+
 #endif /* ODB_HELPER_H */
diff --git a/odb-remote.c b/odb-remote.c
index dbab40c0f8..9a1561430c 100644
--- a/odb-remote.c
+++ b/odb-remote.c
@@ -87,3 +87,20 @@ int odb_remote_get_direct(const unsigned char *sha1)
 
 	return -1;
 }
+
+int odb_remote_get_many_direct(const struct oid_array *to_get)
+{
+	struct odb_helper *o;
+
+	trace_printf("trace: odb_remote_get_many_direct: nr: %d", to_get->nr);
+
+	odb_remote_init();
+
+	for (o = helpers; o; o = o->next) {
+		if (odb_helper_get_many_direct(o, to_get) < 0)
+			continue;
+		return 0;
+	}
+
+	return -1;
+}
diff --git a/odb-remote.h b/odb-remote.h
index 27a480fcfe..e6cedde722 100644
--- a/odb-remote.h
+++ b/odb-remote.h
@@ -4,5 +4,6 @@
 extern struct odb_helper *find_odb_helper(const char *dealer);
 extern int has_odb_remote(void);
 extern int odb_remote_get_direct(const unsigned char *sha1);
+extern int odb_remote_get_many_direct(const struct oid_array *to_get);
 
 #endif /* ODB_REMOTE_H */
-- 
2.17.0.590.gbd05bfcafd




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux