Re: [PATCH 08/17] odb/source: make `close()` function pluggable
- From
Karthik Nayak <karthik.188@gmail.com>
- Date
- Mar 5, 2026, 10:58 UTC
- Message-ID
- <CAOLa=ZRucajqkGeiHM8fvSm2WJFStoBARSC9MH2W02Qw8-7JyA@mail.gmail.com>
- In-Reply-To
- <20260223-b4-pks-odb-source-pluggable-v1-8-253bac1db598@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 14 quoted lines
> diff --git a/odb/source.h b/odb/source.h
> index 2f8132f9e1..7af4900ab4 100644
> --- a/odb/source.h
> +++ b/odb/source.h
> @@ -59,6 +59,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.
> + */Nit: here we say 'may' need to be reopened...
Show 14 quoted lines
> + 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 > @@ -104,6 +112,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. > + */
Here, we're more explicit that it does need to be reopened. I like the latter better, this way, sources which don't need to be re-opened can simply do a no-op. But this makes the expectation on the user side more clear.
Show 11 quoted lines
> +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
>
> --
> 2.53.0.536.g309c995771.dirty