samtools / htslib

C library for high-throughput sequencing data formats
Other
784 stars 447 forks source link

Fix hfile_libcurl small seek bug #1676

Closed daviesrob closed 9 months ago

daviesrob commented 9 months ago

Ensure that to_skip is updated correctly when handling a small seek by skipping data in libcurl_read(). In particular, if the number of bytes returned by wait_perform() exactly matches the number left to skip, to_skip needs to be set to zero, and wait_perform() needs to be called again to get some data for the function to return.

Fixes samtools/samtools#1918; possibly also #1037, #1625 and samtools/samtools#1622

@jmarshall I've made you author of ths commit, as it was your patch. Let me know if you'd like to change anything before it gets merged.

jmarshall commented 9 months ago

The commit and the explanation in the commit message look good.

IMHO you should add a Co-Authored-By: RMD — I just tried a <= tweak and verified that it fixed Alex's problem, but didn't look into how got and to_skip work. You've added the understanding and explanation that this is indeed the right fix in general.

daviesrob commented 9 months ago

Cheers. I've updated the commit message as suggested.