Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions modules/juce_core/native/juce_Network_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ void cancel()
void cancel()
{
const std::scoped_lock lock { mutex };
cancelled = true;
token.cancel();
}

Expand Down Expand Up @@ -423,6 +424,14 @@ bool start (WebInputStream& inputStream, WebInputStream::Listener* listener)
std::unique_lock lock { mutex };
token = std::move (newToken);

// A cancel that arrived while the task was being created found
// an empty token; it is honoured here, before anything waits.
if (cancelled)
{
token.cancel();
return false;
}

while (! condvar.wait_for (lock,
std::chrono::milliseconds { 1 },
[&] { return state != State::beforeStart; }))
Expand Down Expand Up @@ -544,6 +553,7 @@ void willPerformHTTPRedirection (NSURLRequest* urlRequest, void (^completionHand
int statusCode = 0;
int numRedirects = 0;
State state = State::beforeStart;
bool cancelled = false;

SharedResourcePointer<SharedSession> session;
TaskToken token;
Expand Down