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
6 changes: 3 additions & 3 deletions aws-cpp-sdk-transfer/source/transfer/TransferHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ namespace Aws

if(IsTransitionAllowed(currentStatus, value))
{
std::unique_lock<std::mutex> semaphoreLock(m_statusLock);
m_status.store(static_cast<long>(value));

if (IsFinishedStatus(value))
Expand All @@ -238,17 +239,16 @@ namespace Aws
CleanupDownloadStream();
}

std::unique_lock<std::mutex> semaphoreLock(m_statusLock);
m_waitUntilFinishedSignal.notify_all();
}
}
}

void TransferHandle::WaitUntilFinished() const
{
std::unique_lock<std::mutex> semaphoreLock(m_statusLock);
if (!IsFinishedStatus(static_cast<TransferStatus>(m_status.load())) || HasPendingParts())
{
std::unique_lock<std::mutex> semaphoreLock(m_statusLock);
m_waitUntilFinishedSignal.wait(semaphoreLock, [this]()
{ return IsFinishedStatus(static_cast<TransferStatus>(m_status.load())) && !HasPendingParts(); });
semaphoreLock.unlock();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to unlock explicitly? Shouldn't the system unlock it when lock get destructed?

Expand Down Expand Up @@ -301,4 +301,4 @@ namespace Aws
}
}
}
}
}