Checkout
kotkov
committed
on 11 Aug 17
Return resettable streams from svn_stream_checksummed2().

This lays the groundwork required to stream commits over HTTP without
creating te… Show more
Return resettable streams from svn_stream_checksummed2().

This lays the groundwork required to stream commits over HTTP without

creating temporary files.  To switch to the new apply_textdelta_stream()

delta editor callback, we need to make the callback that opens a txdelta

stream restartable, and this is where a resettable checksummed stream

would be handy to have.

Please note that currently the ability to reset a stream, and the new

associated svn_stream_supports_reset() API is tied to the existence of

a non-default seek_fn implementation.  The implementation is free to

_only_ support seek_fn(NULL) requests.  It would probably be slightly

better to have a separate reset_fn callback.  However, we already had it

at some point, and then reverted it in r966156, so let's keep everything

without a separate callback and keep using seek_fn(NULL) for now.

* subversion/include/svn_io.h

 (svn_stream_checksummed2): Note that now this API returns a

  resettable stream.

 (svn_stream_supports_reset): Declare this new function.

* subversion/include/svn_checksum.h

 (svn_checksum_ctx_reset): Declare this new function.

* subversion/libsvn_subr/checksum.c

 (svn_checksum_ctx_reset): Implement this new function.  Forward FNV1-a

  implementations to ...

* subversion/libsvn_subr/fnv1a.h

 (svn_fnv1a_32__context_reset, svn_fnv1a_32x4__context_reset): ...

* subversion/libsvn_subr/fnv1a.c

 (svn_fnv1a_32__context_reset, svn_fnv1a_32x4__context_reset): ...these

  new helper functions.

* subversion/libsvn_subr/stream.c

 (svn_stream_supports_reset): Implement this new function.

 (seek_handler_checksum): Implement the seek handler for checksummed

  streams, only support reset requests for now.

 (svn_stream_checksummed2): Optionally install the new seek handler.

* subversion/tests/libsvn_subr/checksum-test.c

 (test_checksummed_stream_read,

  test_checksummed_stream_reset): New tests.

 (test_funcs): Add new tests.

Show less