From 5550af7e64e5e686eee9171a14c269f55529be09 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Thu, 1 Jun 2023 21:29:37 -0700 Subject: [PATCH] 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 --- Plugins/HTTPSource/HTTPSource.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Plugins/HTTPSource/HTTPSource.m b/Plugins/HTTPSource/HTTPSource.m index 5e1e66218..217d73fad 100644 --- a/Plugins/HTTPSource/HTTPSource.m +++ b/Plugins/HTTPSource/HTTPSource.m @@ -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); }