Skip to content

Commit

Permalink
Increased buffer size [#34]
Browse files Browse the repository at this point in the history
  • Loading branch information
Lejdborg committed Aug 26, 2013
1 parent 95c3413 commit a514b9b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion NMSSH/NMSFTP.m
Expand Up @@ -166,7 +166,7 @@ - (BOOL)removeFileAtPath:(NSString *)path {
- (NSData *)contentsAtPath:(NSString *)path {
LIBSSH2_SFTP_HANDLE *handle = libssh2_sftp_open(self.sftpSession, [path UTF8String], LIBSSH2_FXF_READ, 0);

char buffer[0x4000];
char buffer[kNMSSHBufferSize];
long rc = libssh2_sftp_read(handle, buffer, (ssize_t)sizeof(buffer));
libssh2_sftp_close(handle);

Expand Down
2 changes: 2 additions & 0 deletions NMSSH/NMSSH.h
Expand Up @@ -5,6 +5,8 @@
#import <sys/socket.h>
#import <arpa/inet.h>

#define kNMSSHBufferSize (5*1024*1024)

@class NMSSHSession, NMSSHChannel, NMSFTP;

#import "NMSSHSession.h"
Expand Down
8 changes: 4 additions & 4 deletions NMSSH/NMSSHChannel.m
Expand Up @@ -248,7 +248,7 @@ - (NSString *)execute:(NSString *)command error:(NSError *__autoreleasing *)erro
NSMutableString *response = [[NSMutableString alloc] init];
for (;;) {
ssize_t rc;
char buffer[0x4000];
char buffer[kNMSSHBufferSize];
char errorBuffer[0x4000];

do {
Expand Down Expand Up @@ -379,7 +379,7 @@ - (BOOL)startShell:(NSError *__autoreleasing *)error {
for (;;) {
ssize_t rc;
ssize_t erc;
char buffer[0x4000];
char buffer[kNMSSHBufferSize];
char errorBuffer[0x4000];

do {
Expand Down Expand Up @@ -523,7 +523,7 @@ - (BOOL)uploadFile:(NSString *)localPath to:(NSString *)remotePath {
[self setType:NMSSHChannelTypeSCP];

// Wait for file transfer to finish
char mem[1024];
char mem[kNMSSHBufferSize];
size_t nread;
char *ptr;
while ((nread = fread(mem, 1, sizeof(mem), local)) > 0) {
Expand Down Expand Up @@ -583,7 +583,7 @@ - (BOOL)downloadFile:(NSString *)remotePath to:(NSString *)localPath {
// Save data to local file
off_t got = 0;
while (got < fileinfo.st_size) {
char mem[1024];
char mem[kNMSSHBufferSize];
long long amount = sizeof(mem);

if ((fileinfo.st_size - got) < amount) {
Expand Down

1 comment on commit a514b9b

@tbraly
Copy link

@tbraly tbraly commented on a514b9b Sep 5, 2013

Choose a reason for hiding this comment

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

This breaks things. When doing startShell, you get an exc_bad_access error at runtime. Setting define kNMSSHBufferSize to (8 x 1024) seams to fix the issue.

Please sign in to comment.