mirror of
				https://github.com/libssh2/libssh2.git
				synced 2025-10-27 13:52:22 +03:00 
			
		
		
		
	direct_tcpip: Fixed channel write
There were 3 bugs in this loop: 1) Started from beginning after partial writes 2) Aborted when 0 bytes were sent 3) Ignored LIBSSH2_ERROR_EAGAIN See also: https://trac.libssh2.org/ticket/281 https://trac.libssh2.org/ticket/293
This commit is contained in:
		
				
					committed by
					
						 Daniel Stenberg
						Daniel Stenberg
					
				
			
			
				
	
			
			
			
						parent
						
							14d9ee01bc
						
					
				
				
					commit
					a1e744bb5e
				
			| @@ -275,14 +275,17 @@ int main(int argc, char *argv[]) | ||||
|                 goto shutdown; | ||||
|             } | ||||
|             wr = 0; | ||||
|             do { | ||||
|                 i = libssh2_channel_write(channel, buf, len); | ||||
|             while(wr < len) { | ||||
|                 i = libssh2_channel_write(channel, buf + wr, len - wr); | ||||
|                 if (LIBSSH2_ERROR_EAGAIN == i) { | ||||
|                     continue; | ||||
|                 } | ||||
|                 if (i < 0) { | ||||
|                     fprintf(stderr, "libssh2_channel_write: %d\n", i); | ||||
|                     goto shutdown; | ||||
|                 } | ||||
|                 wr += i; | ||||
|             } while(i > 0 && wr < len); | ||||
|             } | ||||
|         } | ||||
|         while (1) { | ||||
|             len = libssh2_channel_read(channel, buf, sizeof(buf)); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user