Skip to content

Commit

Permalink
Add lock and null check to remoting internals (#16542) (#16683)
Browse files Browse the repository at this point in the history
* fix crash Copy-Item to remote session (#16542)

* update comments

* remove lock (#16542)

Co-authored-by: Sergey Zalyadeev <sergey.zalyadeev@cayosoft.com>
  • Loading branch information
SergeyZalyadeev and Sergey Zalyadeev committed Jan 13, 2022
1 parent 83a809b commit da7c52a
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,21 +220,29 @@ internal void Clear()
lock (_readSyncObject)
{
priorityType = DataPriorityType.Default;

// send data from which ever stream that has data directly.
// Send data from which ever stream that has data directly.
byte[] result = null;
result = _dataToBeSent[(int)DataPriorityType.PromptResponse].ReadOrRegisterCallback(_onSendCollectionDataAvailable);
priorityType = DataPriorityType.PromptResponse;
SerializedDataStream promptDataToBeSent = _dataToBeSent[(int)DataPriorityType.PromptResponse];
if (promptDataToBeSent is not null)
{
result = promptDataToBeSent.ReadOrRegisterCallback(_onSendCollectionDataAvailable);
priorityType = DataPriorityType.PromptResponse;
}

if (result == null)
{
result = _dataToBeSent[(int)DataPriorityType.Default].ReadOrRegisterCallback(_onSendCollectionDataAvailable);
priorityType = DataPriorityType.Default;
SerializedDataStream defaultDataToBeSent = _dataToBeSent[(int)DataPriorityType.Default];
if (defaultDataToBeSent is not null)
{
result = defaultDataToBeSent.ReadOrRegisterCallback(_onSendCollectionDataAvailable);
priorityType = DataPriorityType.Default;
}
}
// no data to return..so register the callback.

// No data to return..so register the callback.
if (result == null)
{
// register callback.
// Register callback.
_onDataAvailableCallback = callback;
}

Expand Down

0 comments on commit da7c52a

Please sign in to comment.