Browse Source

Fix thread synchronization issue when uploading files using SCP

olegkap_cp 12 years ago
parent
commit
f6480f1fff
1 changed files with 2 additions and 2 deletions
  1. 2 2
      Renci.SshClient/Renci.SshNet/SftpClient.cs

+ 2 - 2
Renci.SshClient/Renci.SshNet/SftpClient.cs

@@ -1509,7 +1509,7 @@ namespace Renci.SshNet
                     {
                         if (s.StatusCode == StatusCodes.Ok)
                         {
-                            expectedResponses--;
+                            Interlocked.Decrement(ref expectedResponses); 
                             responseReceivedWaitHandle.Set();
 
                             //  Call callback to report number of bytes written
@@ -1520,7 +1520,7 @@ namespace Renci.SshNet
                             }
                         }
                     });
-                    expectedResponses++;
+                    Interlocked.Increment(ref expectedResponses);
 
                     offset += (uint)bytesRead;