Fixed a couple long-dormant bugs in HttpDataStream

This commit is contained in:
Casey Langen 2020-10-10 21:02:56 -07:00
parent 0d11e3da12
commit e966b36b24

View File

@ -161,7 +161,7 @@ class FileReadStream {
this->underflow.wait(lock); this->underflow.wait(lock);
} }
if (this->interrupted && this->Eof()) { if (this->interrupted || this->Eof()) {
return 0; return 0;
} }
@ -377,13 +377,14 @@ void HttpDataStream::ThreadProc() {
bool HttpDataStream::Close() { bool HttpDataStream::Close() {
this->Interrupt(); this->Interrupt();
this->reader.reset();
if (this->downloadThread) { if (this->downloadThread) {
downloadThread->join(); downloadThread->join();
this->downloadThread.reset(); this->downloadThread.reset();
} }
this->reader.reset();
return true; return true;
} }
@ -435,7 +436,6 @@ size_t HttpDataStream::CurlWriteCallback(char *ptr, size_t size, size_t nmemb, v
size_t result = fwrite(ptr, size, nmemb, stream->writeFile); size_t result = fwrite(ptr, size, nmemb, stream->writeFile);
stream->written += result; stream->written += result;
if (stream->written >= NOTIFY_INTERVAL_BYTES) { if (stream->written >= NOTIFY_INTERVAL_BYTES) {
fflush(stream->writeFile); fflush(stream->writeFile);
stream->reader->Add(stream->written); stream->reader->Add(stream->written);