HTTP Input: Do not hang if transfer completes

If transfer completes quickly, do not hang waiting for it to achieve
reading state. Also add some comments indicating what we're doing.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
main
Christopher Snowhill 2023-06-01 21:29:37 -07:00
parent e0a1cf49e7
commit 5550af7e64
No known key found for this signature in database
1 changed files with 5 additions and 1 deletions

View File

@ -594,11 +594,15 @@ static void http_stream_reset(HTTPSource *fp) {
[NSThread detachNewThreadSelector:@selector(threadEntry:) toTarget:self withObject:nil];
// Wait for transfer to at least start
while(status == STATUS_UNSTARTED) {
usleep(3000);
}
while(status != STATUS_READING && curl) {
// Now wait for it to either begin streaming, or complete if file is small enough to fit in the buffer
while(status != STATUS_READING &&
status != STATUS_FINISHED &&
curl) {
usleep(3000);
}