Skip to content

Commit

Permalink
Fix channel state handling
Browse files Browse the repository at this point in the history
Shouldn't try and recv data when the channel is closed.
  • Loading branch information
wtsnz committed Feb 15, 2021
1 parent a2acd32 commit 1465c82
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions deps/portal/src/Channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,18 @@ void Channel::InternalThreadEntry()
while (running) {
std::unique_lock<std::mutex> lock(worker_mutex);

if (getState() == State::Errored) {
return;
}

// Receive some data
const uint32_t numberOfBytesToAskFor = 1 << 18; // 262,144
uint32_t numberOfBytesReceived = 0;
auto vector = std::vector<char>(numberOfBytesToAskFor);
uint32_t numberOfBytesReceived = 0;
auto vector = std::vector<char>(numberOfBytesToAskFor);

int ret = usbmuxd_recv_timeout(conn, vector.data(),
numberOfBytesToAskFor,
&numberOfBytesReceived, 1000);
int ret = usbmuxd_recv_timeout(conn, vector.data(),
numberOfBytesToAskFor,
&numberOfBytesReceived, 1000);

if (ret == 0) {
if (getState() == State::Connecting) {
Expand Down

0 comments on commit 1465c82

Please sign in to comment.