From 3bc3177ad7a472dd5fc45cff16b8f57e5800ebc2 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 5 Mar 2026 15:19:48 +0100 Subject: odb/source: make `close()` function pluggable Introduce a new callback function in `struct odb_source` to make the function pluggable. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- odb/source.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'odb/source.h') diff --git a/odb/source.h b/odb/source.h index 09cca839fe..0e6c6abdb1 100644 --- a/odb/source.h +++ b/odb/source.h @@ -58,6 +58,14 @@ struct odb_source { */ void (*free)(struct odb_source *source); + /* + * This callback is expected to close any open resources, like for + * example file descriptors or connections. The source is expected to + * still be usable after it has been closed. Closed resources may need + * to be reopened in that case. + */ + void (*close)(struct odb_source *source); + /* * This callback is expected to clear underlying caches of the object * database source. The function is called when the repository has for @@ -103,6 +111,16 @@ void odb_source_free(struct odb_source *source); */ void odb_source_release(struct odb_source *source); +/* + * Close the object database source without releasing he underlying data. The + * source can still be used going forward, but it first needs to be reopened. + * This can be useful to reduce resource usage. + */ +static inline void odb_source_close(struct odb_source *source) +{ + source->close(source); +} + /* * Reprepare the object database source and clear any caches. Depending on the * backend used this may have the effect that concurrently-written objects -- cgit v1.3-5-g9baa